Skip to content
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 a new rule to warn against usage of __file__ module attribute #9122

Open
edgarrmondragon opened this issue Dec 13, 2023 · 2 comments
Open
Labels
rule Implementing or modifying a lint rule

Comments

@edgarrmondragon
Copy link
Contributor

Using the __file__ module attribute can be problematic in library code. According to PyOxydizer:

Use of __file__ is commonly encountered in code loading resource files. See Loading Resource Files for more on this topic, including how to port code to more modern Python APIs for loading resources.

This is also a problem for zipapps.

Using __file__ is fine for scripts, so if this accepted I'm not sure what plugin this make the most sense to live in.

@edgarrmondragon edgarrmondragon changed the title Add a new rule to warn against usage of __file__ Add a new rule to warn against usage of __file__ module attribute Dec 13, 2023
@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Jan 25, 2024
@nathanjmcdougall
Copy link

Some further writeup on the issue:
indygreg/PyOxidizer#69 (comment)

@edgarrmondragon
Copy link
Contributor Author

I wonder if this makes sense as part of RUF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

No branches or pull requests

3 participants