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
Address misleading import behavior when given files #51
Comments
Hi @asmeurer, thanks for posting! The cause here is the difference between running I agree though that this could be made more explicit, as the behavior of running with
What are your thoughts on the preferred solution? |
Is it not possible to make it "just work", e.g., by making sure the current directory is at the front of the sys.path? If I pass it a file or path, I would expect it to operate on that path, especially given that there is a separate -m option to pass a module. I'm unclear why you would ever want the current behavior. I must be misunderstanding the workflow you are describing in your point number 2. |
I do agree that I'm hesitant to automatically adjust I'd therefore suggest this change:
|
I'm a little unclear why it even works this way to begin with. Isn't |
@asmeurer that was my impression as well, but I discovered recently that
Why does this even work in the first place then? That behavior can result in surprising behavior, and should be changed. |
It sounds to me like slotscheck should always add the parent directory of the given module to the path before importing. Based on what you are saying, even if you did Actually it would be more complicated than that because you might get passed a submodule or a specific .py file, so you'd have to check for |
What happens when given
The implicit namespace package discovery seems to have been solved by |
I meant the case when Regarding implicit namespace packages, IMO I wouldn't care about those unless someone requests it (I still frankly don't understand when you would ever want to use one). |
|
This explicit check is implemented in v0.11. Example of the message:
|
I found it somewhat misleading when I ran
slotscheck mymod/
and it instead tested the installed version ofmymod
. This is especially since the command line options seem to imply that the argument is a file unless the-m
option is provided.I also tried this in an environment that doesn't have my module installed and it couldn't import it, which I also found surprising given that the module is there in the directory I ran slotscheck from.
The text was updated successfully, but these errors were encountered: