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

Fix pre-commit mypy and standardizing environment setup #120

Merged
merged 11 commits into from
Dec 20, 2024

Conversation

blsmxiu47
Copy link

Description

@zhengp0 mentioned issues with local environment setup (I think conflicting conda envs iirc) and difficulty pointing to the correct mypy executable while developing. I also noticed that mypy would need to be run manually (which is not bad practice, but still) prior to commit in order to catch typing issues early, rather than it automatically.

So,

  1. fixed an incorrect line in .pre-commit-config.yaml to ensure it always runs for all python files in src/ and tests/ (files updated within the commit in question, that is) to enable automatic pre-commit type checking.
  2. More significantly, added a Makefile that provides some environment setup-related targets that may be useful in order to ensure the local dev environment is set up correctly. As a part of this PR I removed my previous conda environment and tested setting up in this manner (i.e. make setup ENV_TYPE=conda, then conda activate onemod) and can confirm that my mypy, pytest, etc. executables all point to the expected locations within the new ("onemod") conda environment so please do let me know if this approach still does not work for you using this branch.

Changes made

  • One-line regex fix to .pre-commit-config.yaml
  • Adds Makefile with (optional but maybe useful) environment setup targets
  • Adds drafts for some getting started dev documentation for the Makefile additions, though have not yet approached the task of rewriting all dev docs for the redesign
  • Adds a potential CONTRIBUTING.md skeleton for discussion. Would want to discuss contribution guidelines together though before filling in. May not be highest priority atm.

Makefile Show resolved Hide resolved
Makefile Show resolved Hide resolved
.pre-commit-config.yaml Outdated Show resolved Hide resolved
@kels271828
Copy link
Member

Thanks for setting all of this up!

@kels271828
Copy link
Member

Does anyone else get this error when running ruff:

warning: The isort option isort.split-on-trailing-comma is incompatible with the formatter format.skip-magic-trailing-comma=true option. To avoid unexpected behavior, we recommend either setting isort.split-on-trailing-comma=false or format.skip-magic-trailing-comma=false.

I can fix this by adding this to pyproject.toml:

[tool.ruff.lint.isort]
split-on-trailing-comma = false

Just wasn't sure if I'm the only one seeing this error.

@kels271828
Copy link
Member

After running pre-commit, I get a lot of files changed because of the end-of-file-fixer. Should we add those file changes to this PR?

… dependencies types-PyYAML; include .env vars in Makefile
@blsmxiu47
Copy link
Author

We can definitely remove the make mypy, make pre-commit targets before merging this branch; first just want to ensure that @zhengp0 can get setup successfully.

@blsmxiu47
Copy link
Author

@kels271828 Added in the

[tool.ruff.lint.isort]
split-on-trailing-comma = false

as you suggested. I was also getting that warning.

Also fixed some of the docs syntax, added .env vars note to the dev docs, and as for the :ref:s, these links look and work fine when building and viewing locally, but not sure if there's a way to get them functioning when viewing in GitHub(?) Would be interested if you know of a way 😅

@kels271828
Copy link
Member

Also fixed some of the docs syntax, added .env vars note to the dev docs, and as for the :ref:s, these links look and work fine when building and viewing locally, but not sure if there's a way to get them functioning when viewing in GitHub(?) Would be interested if you know of a way 😅

Maybe it's just an issue with viewing on GitHub; I was just viewing it in the browser not actually building the documentation with sphinx

Copy link
Member

@zhengp0 zhengp0 left a comment

Choose a reason for hiding this comment

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

Thanks @blsmxiu47 ! Run through with no issue :)

@blsmxiu47 blsmxiu47 merged commit c477814 into release/1.0 Dec 20, 2024
6 of 9 checks passed
@blsmxiu47 blsmxiu47 deleted the bugfix/fix-pre-commit-mypy branch December 20, 2024 21:45
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.

3 participants