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

Replace linter and formatter with ruff and mypy #392

Merged
merged 6 commits into from Jan 18, 2024
Merged

Conversation

lan496
Copy link
Member

@lan496 lan496 commented Jan 12, 2024

Closes #364

.pre-commit-config.yaml Outdated Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
test/functional/python/test_spglib.py Show resolved Hide resolved
Copy link
Collaborator

@LecrisUT LecrisUT left a comment

Choose a reason for hiding this comment

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

Also, just make sure when you apply pre-commit it's a separate commit, and we don't squash commit for this PR

pyproject.toml Outdated Show resolved Hide resolved
@@ -40,7 +40,7 @@
import numpy as np

try:
from spglib import _spglib as spg
from spglib import _spglib as spg # type: ignore
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the ignore? Also should scope ignores

Copy link
Member Author

Choose a reason for hiding this comment

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

Without ignoring, mypy says

error: Module "spglib" has no attribute "_spglib"  [attr-defined]

Copy link
Collaborator

@LecrisUT LecrisUT Jan 12, 2024

Choose a reason for hiding this comment

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

Yeah, but that's a genuine issue:

  • We should be using relative paths there
  • We should be providing a _spglib.pyi to type-hint the C interface, even if only internally

Copy link
Member Author

Choose a reason for hiding this comment

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

The relative path did not persuade mypy

    from .spglib import _spglib as spg
# -> Module "spglib.spglib" has no attribute "_spglib"  [attr-defined]

.pre-commit-config.yaml Outdated Show resolved Hide resolved
@LecrisUT
Copy link
Collaborator

Also worth referencing the scienitific-python configuration: https://github.com/scientific-python/cookie/blob/main/pyproject.toml

@codecov-commenter
Copy link

codecov-commenter commented Jan 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ba444f4) 83.86% compared to head (a28e63f) 83.86%.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #392   +/-   ##
========================================
  Coverage    83.86%   83.86%           
========================================
  Files           24       24           
  Lines         8180     8180           
========================================
  Hits          6860     6860           
  Misses        1320     1320           
Flag Coverage Δ
c_api 77.59% <ø> (ø)
fortran_api 56.15% <ø> (ø)
python_api 80.38% <ø> (ø)
unit_tests 1.24% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@LecrisUT
Copy link
Collaborator

LecrisUT commented Jan 13, 2024

Please split the "add mypy/ruff configuration" and "apply mypy/ruff” as separate commits in 31b2842. You can run git commit --no-verify to skip the pre-commit

@lan496 lan496 changed the title Replace linter and formatter with ruff Replace linter and formatter with ruff and mypy Jan 14, 2024
@lan496 lan496 requested a review from LecrisUT January 17, 2024 10:44
Copy link
Collaborator

@LecrisUT LecrisUT left a comment

Choose a reason for hiding this comment

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

👍 for the current setup as an initial implementation. Mind if I rebase your commits a bit before merging?

exclude: database
pass_filenames: false
Copy link
Collaborator

@LecrisUT LecrisUT Jan 18, 2024

Choose a reason for hiding this comment

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

The size of the python bindings is very small, so might as well run mypy on all sources defined in pyproject.toml, i.e. running

$ mypy --ignore-missing-imports --scripts-are-modules

@lan496
Copy link
Member Author

lan496 commented Jan 18, 2024

@LecrisUT No problem. I'll leave the rest to you.

Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
@LecrisUT
Copy link
Collaborator

Sorry, had to change the committer because I've split the commits. Btw, can you add docs/readthedocs.org, and testing-farm:fedora-39 (and later fedora-38 as well) to the required workflows to pass? Otherwise if we use auto-merge now it would keep those checks dangling.

Also make sure to merge this with a merge commit or rebase to keep the history

@lan496
Copy link
Member Author

lan496 commented Jan 18, 2024

Thanks to tidy commits. I've updated the branch protection rule. Is it OK?
image

@LecrisUT
Copy link
Collaborator

Yep, that looks good. I'll bother you again later when I enable Fedora38

@lan496 lan496 merged commit 5ce87bc into spglib:develop Jan 18, 2024
33 of 45 checks passed
@lan496 lan496 deleted the linter branch January 18, 2024 22:28
@LecrisUT LecrisUT added this to the 2.3 milestone Jan 25, 2024
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.

ci: Modernize the CI tools
3 participants