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

Enforce python naming convention #66

Open
eirikurj opened this issue Nov 22, 2024 · 3 comments
Open

Enforce python naming convention #66

eirikurj opened this issue Nov 22, 2024 · 3 comments

Comments

@eirikurj
Copy link
Contributor

Description of feature

Our python code is mostly CamelCase, but there are exceptions. To keep the python MDO Lab codebase and APIs consistent and predicable, we could and probably should integrate some tools into our testing to enforce this.

Potential solution

There are several tools available, but one option that fits into our current tools is to use the flake8 extension, pep8-naming.

Feel free to suggest other tools or approaches.

@ewu63
Copy link
Collaborator

ewu63 commented Nov 22, 2024

So the actual standard for Python is to use snake_case for functions and variables (as noted in PEP8) and somewhat enforced by the flake8 extension you linked. The fact that we (implicitly) used camelCase always bothered me but it's probably too difficult to change at this point, though automatic tools such as this one that leverages rope exists. Perhaps worth a discussion.

@eirikurj
Copy link
Contributor Author

Yeah you are right, we are not really following PEP8 that well. They do however state in the link you posted that

mixedCase is allowed only in contexts where that’s already the prevailing style (e.g. threading.py), to retain backwards compatibility.

The tool does seem to support mixedCase and can maybe be of use just to get something going that is automated. I have however not tested the tool myself, but my main motivation was just to get some discussion started and seek out tools.
As you said , converting to snake_case is an option but would be a major change. Not sure if we want to do that unless there is a compelling reson and benefits of doing so.

@ewu63
Copy link
Collaborator

ewu63 commented Nov 30, 2024

Yeah, I also think renaming all the variables will be fairly disruptive. However, I have not seen any linters which support non-PEP8 naming standards. For example, the one you linked (pep8-naming) will throw a ton of N806 errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants