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

Linting and code formatting #131

Open
2 of 4 tasks
stefsmeets opened this issue Aug 8, 2024 · 11 comments
Open
2 of 4 tasks

Linting and code formatting #131

stefsmeets opened this issue Aug 8, 2024 · 11 comments
Labels
Priority 3: standard Priority level 3: medium time criticality or importance software Relating to software and implementation

Comments

@stefsmeets
Copy link
Contributor

stefsmeets commented Aug 8, 2024

Hi all, I'm wondering what is your opinion on code formatting and linting. I think PROTEUS and some of the other submodules would really benefit from some linting.

I personally find ruff to be a great tool for linting, formatting, and import sorting. Let me know what you think.

@timlichtenberg
Copy link
Collaborator

Sounds useful, I would suggest to discuss this at the next PROTEUS meeting on Monday; it would be good if you could describe a bit what steps and changes this would induce.

@nichollsh
Copy link
Contributor

nichollsh commented Aug 8, 2024

I agree that we need to have something like this going forward, as more people are working on the code. I am particularly a fan of implementing more typed code.

A maximum line length also makes sense, but may I also suggest a larger limit of 92 chars rather than 79?

@nichollsh
Copy link
Contributor

In addition, we should discuss what kind of naming style is appropriate for variables, functions, etc. The PEP doesn't specify a single style in particular.

The predominant style in the current code is CamelCase, with a few exceptions.

@stefsmeets
Copy link
Contributor Author

stefsmeets commented Aug 8, 2024

The standard is CamelCase for classes and snake_case for methods, functions, and variables. Globals in UPPERCASE. See: https://peps.python.org/pep-0008/#descriptive-naming-styles

And +1 for 92 or perhaps even larger for line length.

@stefsmeets
Copy link
Contributor Author

stefsmeets commented Aug 22, 2024

Current state of the code:

❯ ruff check src/* tests/* --statistics --select F,E,W,I
118	E501	[ ] line-too-long
 39	F821	[ ] undefined-name
 36	W291	[*] trailing-whitespace
 24	E701	[ ] multiple-statements-on-one-line-colon
 15	F841	[*] unused-variable
 10	E711	[*] none-comparison
  8	E702	[ ] multiple-statements-on-one-line-semicolon
  6	E741	[ ] ambiguous-variable-name
  5	W293	[*] blank-line-with-whitespace
  3	E721	[ ] type-comparison
  3	E731	[*] lambda-assignment
  2	E712	[*] true-false-comparison
  1	E713	[*] not-in-test
  1	F601	[*] multi-value-repeated-key-literal

Undefined name is somewhat worrying, but seems to be a side-effect of #138

@stefsmeets
Copy link
Contributor Author

Hi all, just noticed that I pushed a bunch of commits to master by accident that addresses this issue, just so you know. I can't undo it because of branch protection, but I will fix remaining issues next week. Sorry about that.

@timlichtenberg
Copy link
Collaborator

How did this work in the first place?

@stefsmeets
Copy link
Contributor Author

No idea, I forgot to ceate a branch so I committed to master (locally) instead and pushed that 😅 It also struck me that it's kind of odd that the branch protection does not protect against that. I tried to undo and force push the previous state, but that actually is forbidden. Best I can do is revert the changes in a new commit and then push that. Just messes up the history a bit.

@stefsmeets
Copy link
Contributor Author

stefsmeets commented Aug 23, 2024

@nichollsh
Copy link
Contributor

It is turned off. Should we turn it on?

@timlichtenberg
Copy link
Collaborator

Good for me now that every repo has 4 admins.

@lsoucasse lsoucasse added the software Relating to software and implementation label Nov 11, 2024
@timlichtenberg timlichtenberg added the Priority 3: standard Priority level 3: medium time criticality or importance label Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority 3: standard Priority level 3: medium time criticality or importance software Relating to software and implementation
Projects
None yet
Development

No branches or pull requests

4 participants