-
Notifications
You must be signed in to change notification settings - Fork 206
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
"camelcase imported as lowercase" failure in an import of a package or module #201
Comments
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Holding a sleeping newborn so I'm going to be terse and respond to exactly I've point you made
In the example you gave you otherwise would have had a camelcase name to reference everywhere |
Congratulations on your newborn! Don't mind paying attention to this issue at least for the next 3 years or so! :- ) Let me try to rephrase the issue. In import foo.bar.baz as fbb # foo, foo.bar, and foo.bar.baz imported, foo.bar.baz bound as fbb
from foo.bar import baz # foo, foo.bar, and foo.bar.baz imported, foo.bar.baz bound as baz The issue is that |
So i think the disconnect between you and me is based on what an import might be used like if not allowed to a different casing. Two examples you have have a fully qualified band that is now mixed case without any alias. Using the Salesforce library to start with, I believe that changing that to I do think the Again, she caveats if holding a newborn and replying on mobile with one have |
I see what you mean.
Maybe we can simplify the question to: When you look at |
I think I have a solution that makes more sense, in PEP8 terms, than the discussion I started above (and sorry if that was confusing). Given that
and
(from https://docs.python.org/3/tutorial/modules.html#packages) Then I propose:
|
I think those generally sound like good rules, they sort of fall outside the bounds of PEP 8. The Package and Module Names section tells us how a (source) module should be named, but I don't know if we should be adding enforcement to Your second proposed rule feels closest in spirit to PEP 8. I'm less sure about the first one. |
Agree. That's the point of the second proposed rule (not to force the case type to the If we also want to enforce the packages and modules in the code being linted to be lowercase, maybe we could check the directory and file names. But that might be a separate discussion...
What are you not sure about the first proposed rule? The way I see it, rules N81{1,2,3,4,7} are already enforcing that aliases have the same case type as the imported item. I'm proposing these rules to be more specific (only be applied in imports in the form |
I understand better now. I thought you were proposing that we change the check to enforce that the alias simply matches the case of the imported name, skipping the other naming rules. |
Cool. Let me work on the code changes and propose then in a PR. |
Hi. Can we have a second look at this? Maybe I didn't express myself well before. The goal is to check the PEP 8 package and module names convention is applied to aliases of imported packages or modules. So given
We won't check for the case of EDIT: This rule will be specific for the
(from https://docs.python.org/3/tutorial/modules.html#packages) |
For example, this code:
fails with:
Shouldn't pep-naming just
look at the package name being imported (consider this is an import of a package or module, and then not fail in this case?commons
) instead of looking at the parent package names tooI'm assuming this rule exists for when a class name is being imported, as discussed in https://stackoverflow.com/a/37590149/2654518. In this case:
sure should fail with:
The text was updated successfully, but these errors were encountered: