-
Notifications
You must be signed in to change notification settings - Fork 7
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
Step 5: Linting and formatting #73
base: master
Are you sure you want to change the base?
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good coding practice to use code formatters/linters. But firefly-client didn't get the chance to implement it because of limited resources. Ruff is top choice (I've used it in other projects) but firefly team should decide it first before implementing it.
"""Definition of stretch type (`dict`).""" | ||
INVERSE_STRETCH_TYPE = {v: k for k, v in STRETCH_TYPE_DICT.items()} | ||
INVERSE_STRETCH_TYPE: ClassVar = {v: k for k, v in STRETCH_TYPE_DICT.items()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you intend to introduce types in this PR? I thought it was only for code-formatting/linting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lint included in the ruff default lints that complains about class variables that mutate not being explicitly typed as class variables, so that meta type was added. However, with it being a meta type and not a static type, it has no effect on the code.
I would suggest looking at linting rules. The explicit linter that's used doesn't matter as much as the rules. For instance,
If you remove the RUF rules, the same effect could be achieved by installing A complete list of rules that can be used can be found here: https://docs.astral.sh/ruff/rules |
I want to hold off on the PR. The idea is fine but we want to have some time to evaluate coding practices. I don't want to jump into something that i have not had time to think about. Based on resources this is probably not going to happen very fast. |
This PR adds common linting and formatting rules to the code base using
ruff
.I configured
ruff
with the defaults for code quality as specified in the documentation forruff
. To ensure standard code formatting, you can runruff format
, which will format all files (including the jupyter notebooks) following the PEP standards and the configuration stated in the[tool.ruff]
sections of thepyproject.toml
. To ensure standard linting and to stay up to date with general python code standards, you can also runruff check
to lint all files. This will output all linting errors, warnings, and suggestions. You may also useruff check --fix
to automatically fix the linting rules that have auto-corrections. Note thatruff format
norruff check --fix
will rewrite any logic. These commands will only modify the syntax of the code.