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 formatting, semi-lax. #172

Merged
merged 8 commits into from
Oct 31, 2023

Conversation

terjekv
Copy link
Collaborator

@terjekv terjekv commented Sep 2, 2023

Initial linting and formatting adherence

  • tox now runs black and ruff on the project (the environment is called lint).
  • tox runs ruff with --fix to resolve fixable issues.
  • CI integration for tox is added to the test job.

Code changes

To adhere to even semi-lax linting, there were changes required in the code. These are:

  • Migrated use of python builtin identifiers (type, id, and print) to more appropriate names.
  • Some cases of long string literals were using implicit concatenation, which is now explicit (by adding a set of parentheses)
  • Note that unused imports without # noqa: F401 following the import will be removed by ruff.
  • Exception handling demanded work as there were unspecified exception catching (except Exception rewritten to explicit exceptions) and cases where exceptions within exceptions did not specify if one was to include the previous exception or not (use from either from the previous exception or None explicitly).

Outstanding changes with current settings

  • print in history.py (shadowing builtin) was not fixed as it needs a bit more debugging to figure out exactly how it is used.

Notes

There is still a lot to do with regards to linting, formatting, and typing. This PR does not seek to resolve these issues, but attempts to create a baseline of requirements for the codebase to adhere to.

  - `tox` now runs `black` and `ruff` on the project (the environment is called `lint`).
  - tox runs `ruff` with --fix to resolve fixable issues.
  - There is no pre-commit hook or CI integration as of yet.

### Code changes

To adhere to even semi-lax linting, there were changes required in the code. These are:

- Migrated use of python builtin identifiers (`type`,  `id`, and `print`) to more appropriate names.
- Some cases of long string literals were using implicit concatenation, which is now explicit (by adding a set of parentheses).

### Outstanding changes with current settings

- `print` in history.py (shadowing builtin) was not fixed as it needs a bit more debugging to figure out exactly how it is used.

### Notes

There is still a lot to do with regards to linting, formatting, and typing. This PR does not seek to resolve these issues, but attempts to create a baseline of requirements for the codebase to adhere to.
  - In the future it would probably be a good idea to integreate `ci/run_testsuite_and_record.sh` into the tox setup.
Copy link
Contributor

@oyvindhagberg oyvindhagberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a lot to read through, with all the whitespace and quotation mark changes. But it looks good to me ™️

@terjekv terjekv merged commit c043fa6 into unioslo:master Oct 31, 2023
11 checks passed
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

Successfully merging this pull request may close these issues.

2 participants