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

Subtle misc. refactors and lint suggestions #104

Merged
merged 5 commits into from
Dec 19, 2024

Conversation

mwtoews
Copy link
Contributor

@mwtoews mwtoews commented Dec 18, 2024

This PR has several miscellaneous refactors and applied lint suggestions via ruff check rules:

  • Apply pydocstyle rules with "google" convention; these changes were mostly automated with a few manual edits for line lengths
  • Apply isort (I) rule
  • Apply pyupgrade (UP) rule, which uses format() instead of % formats
  • Better use of pytest.approx() rather than assert round(... expressions

The only subtle change in this PR that is arguably not a refactor is to __new__, which will enforce float types. For instance, before this was the behavior:

>>> import numpy as np
>>> from affine import Affine
>>> Affine(*np.arange(6, dtype=np.float32))
Affine(np.float32(0.0), np.float32(1.0), np.float32(2.0),
       np.float32(3.0), np.float32(4.0), np.float32(5.0))

now with this PR the properties are all Python-native float types.

>>> Affine(*np.arange(6, dtype=np.float32))
Affine(0.0, 1.0, 2.0,
       3.0, 4.0, 5.0)

@mwtoews
Copy link
Contributor Author

mwtoews commented Dec 18, 2024

The previous CI error is because ubuntu-latest was switching to ubuntu-24.04, so pinning back to ubuntu-22.04 for now.

Copy link
Member

@sgillies sgillies left a comment

Choose a reason for hiding this comment

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

Cool! There are a couple changes I'd like to see.

affine/__init__.py Outdated Show resolved Hide resolved
affine/__init__.py Outdated Show resolved Hide resolved
affine/__init__.py Outdated Show resolved Hide resolved
affine/__init__.py Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
Copy link
Member

@sgillies sgillies left a comment

Choose a reason for hiding this comment

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

Thanks @mwtoews ! Anything else?

@mwtoews
Copy link
Contributor Author

mwtoews commented Dec 19, 2024

I think that's it! Expect a docstyle PR soonish.

@sgillies sgillies merged commit 64b7327 into rasterio:main Dec 19, 2024
7 checks passed
@mwtoews mwtoews deleted the improve-lints-opts branch December 19, 2024 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants