-
Notifications
You must be signed in to change notification settings - Fork 121
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
refactor: Avoid implicit reexport in tests #538
refactor: Avoid implicit reexport in tests #538
Conversation
cc5f7f5
to
dd176cd
Compare
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.
This looks good to me, but I know there has been some discussion about how to do these imports in other PRs, so I want to make sure I understand the benefits.
It seems like this changes what is implicitly re-exported rather than removing any implicit re-exports (which would be impossible). For instance, we can no longer do this:
from tests.extensions.test_custom import pystac
...but we can now do this:
from tests.extensions.test_custom import Link, Asset, RangeSummary, ...
Is the ultimate goal here to help eliminate circular imports or is there another aim? Also, if there are some documented best practices on this that I've missed feel free to just link to those and I can read up on it myself; this is mostly for my own understanding.
Thanks!
I guess maybe my real question is why |
That's right; basically, importing from the place where something is defined rather than indirectly via
When I started the work on this I simply assumed that mypy was doing the right thing, since I'm used to empty On the other hand, the documentation mentions how including values in tl;dr: I might not understand imports as well as I'd hoped, but it looks like emptying out the Update: Nope,
Update 2: Turns out that was because those files were doing Update 3: Getting rid of those duplicate imports resulted in reintroducing the circular imports, so that's out. |
Yeah, I agree that this is definitely the way to go for both the tests and the code base in general. My only hesitation is that it's nice for users to be able to do something like |
I forgot to mention, I think there is a workaround to get the best of both worlds: avoid reexports inside of pystac itself, but import everything we expect the users to use into the root |
dd176cd
to
359c9b2
Compare
This would definitely be the ideal situation; it would be nice not to change the way users have to import from |
I've tried to pull apart some of the circular imports, but without success so far. |
Related Issue(s): #332
Description: First step towards
strict = True
mypy setting.PR Checklist:
pre-commit run --all-files
)scripts/test
)