-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add private function calls check to make sure there isn't one being called outside of the module it was defined #9138
Comments
Is this similar to |
Perhaps it could be an extension to that rule, @charliermarsh. My code doesn't check for class private member access. It checks for module private member access. Here's an example of something that should raise an exception: # a.py
def _foo(*args, **kwargs):
return "Hello World" # b.py
import a
print(a._foo()) # Raises an exception # c.py
from a import _foo
print(_foo()) # Also raises an exception Have I misunderstood the rule you've mentioned, or am I really onto something here? |
I believe this would be closed by #5920. |
Indeed, @charliermarsh. Thanks for pointing that out, I didn't see that issue before. |
## Summary Implements [`import-private-name` (`C2701`)](https://pylint.pycqa.org/en/latest/user_guide/messages/convention/import-private-name.html) as `import-private-name` (`PLC2701`). Includes documentation. Related to #970. Closes #9138. ### PEP 420 namespace package limitation `checker.module_path` doesn't seem to support automatic detection of namespace packages (PEP 420). This leads to 'false' positives (Pylint allows both). Currently, for this to work like Pylint, users would have to [manually input known namespace packages](https://beta.ruff.rs/docs/settings/#namespace-packages). ## Test Plan `cargo test`
I have drafted a pre-commit hook to make sure there isn't a private function being called outside of the module it was defined. Would it make sense as an optional linting rule? If so I'd be happy to contribute with code.
The text was updated successfully, but these errors were encountered: