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

warning for variable that can be marked as Final #5047

Open
DetachHead opened this issue Sep 20, 2021 · 3 comments
Open

warning for variable that can be marked as Final #5047

DetachHead opened this issue Sep 20, 2021 · 3 comments
Labels
Enhancement ✨ Improvement to a component Hacktoberfest Help wanted 🙏 Outside help would be appreciated, good for new contributors High effort 🏋 Difficult solution or problem to solve Needs specification 🔐 Accepted as a potential improvement, and needs to specify edge cases, message names, etc.

Comments

@DetachHead
Copy link
Contributor

Current problem

i would like to have this eslint rule for python

Desired solution

a warning that detects when a variable isn't annotated with Final and isn't being modified

Additional context

No response

@DetachHead DetachHead added Enhancement ✨ Improvement to a component Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Sep 20, 2021
@Pierre-Sassoulas Pierre-Sassoulas removed the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Sep 20, 2021
@cdce8p
Copy link
Member

cdce8p commented Sep 20, 2021

Not sure how practical or even possible it would be. In contrast to TypeScript, Python doesn't have an explicit export keyword. As such any module level variable could theoretically be used in another module without pylint knowing about it.

It might be possible (although still difficult) on a function scope bases, but then how often would do you annotate function variables with Final? At least from my experience, this isn't something I normally do.

@DetachHead
Copy link
Contributor Author

how often would do you annotate function variables with Final? At least from my experience, this isn't something I normally do.

To be honest I rarely used it either but only because I forgot it exists. Now that I remember it I see no reason not to use it as often as I use const in typescript

@cdce8p
Copy link
Member

cdce8p commented Sep 20, 2021

how often would do you annotate function variables with Final? At least from my experience, this isn't something I normally do.

To be honest I rarely used it either but only because I forgot it exists. Now that I remember it I see no reason not to use it as often as I use const in typescript

Please do by all means. I just don't think a pylint check would be worth it. Especially considering the required effort to get it to work. Just to give you an example, the somewhat related check undefined-variable is one of the most complex checks we have currently. So many corner cases to consider (and potentially miss).

@Pierre-Sassoulas Pierre-Sassoulas added Help wanted 🙏 Outside help would be appreciated, good for new contributors High effort 🏋 Difficult solution or problem to solve Hacktoberfest labels Sep 21, 2021
@Pierre-Sassoulas Pierre-Sassoulas added the Needs PR This issue is accepted, sufficiently specified and now needs an implementation label Jun 24, 2022
@Pierre-Sassoulas Pierre-Sassoulas added Needs specification 🔐 Accepted as a potential improvement, and needs to specify edge cases, message names, etc. and removed Needs PR This issue is accepted, sufficiently specified and now needs an implementation labels Jul 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component Hacktoberfest Help wanted 🙏 Outside help would be appreciated, good for new contributors High effort 🏋 Difficult solution or problem to solve Needs specification 🔐 Accepted as a potential improvement, and needs to specify edge cases, message names, etc.
Projects
None yet
Development

No branches or pull requests

3 participants