-
Notifications
You must be signed in to change notification settings - Fork 122
[Python] Add tests for recursive imports #2533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| Naive implementation can have depenency due to typing. To break it we should be | ||
| using TYPE_CHECKING imports. Otherwise, there is a cycle between | ||
| databricks.bundles.core.Resource and databricks.bundles.jobs.Job | ||
| (or other resources). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully understand this paragraph, can you rephrase?
| original_modules = sys.modules.copy() | ||
|
|
||
| for module in original_modules.keys(): | ||
| if module.startswith("databricks.bundles"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as below (can be a constant).
| if module.startswith("databricks.bundles"): | |
| if module.startswith("databricks.bundles."): |
e196ef9 to
9b491b9
Compare
| "pytest-cov==5.0.0", | ||
| "pytest==8.3.3", | ||
| "ruff==0.6.8", | ||
| "ruff==0.9.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's necessary because otherwise ruff in GH actions doesn't agree with ruff in experimental/python
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(ideally this is a separate PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍, fixed in #2566
|
@pietern, thanks for the suggestions. I've refactored the code and comments to make it more straightforward. |
| "pytest-cov==5.0.0", | ||
| "pytest==8.3.3", | ||
| "ruff==0.6.8", | ||
| "ruff==0.9.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(ideally this is a separate PR)
aac98a4 to
70b3edd
Compare
Changes
Add tests for recursive imports.
Right now, we have carefully crafted all imports so it isn't a problem. We need tests to avoid regressions. For example, previously, we had a problem with importing from
databricks.bundles.jobsbeforedatabricks.bundles.coreresulted in errors. And introducing such regression in the code doesn't break any existing tests.Tests
Unit test