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

chore: drop isort config, require annotation imports #2801

Merged
merged 7 commits into from
Nov 7, 2023

Conversation

agoose77
Copy link
Collaborator

@agoose77 agoose77 commented Nov 6, 2023

This PR updates our linting rules to always require annotation module imports. This was inspired by the default in https://github.com/scientific-python/cookie

We also update the tests. I would probably prefer to allow the tests to skip this import, but it doesn't seem possible to do this at the moment, so let's just make life easy and impose the same rules for all source files.

@agoose77 agoose77 requested a review from jpivarski November 6, 2023 16:59
Copy link

codecov bot commented Nov 6, 2023

Codecov Report

Merging #2801 (6f3678c) into main (bd4cb8d) will increase coverage by 0.14%.
The diff coverage is 85.71%.

❗ Current head 6f3678c differs from pull request most recent head 6c694f7. Consider uploading reports for the commit 6c694f7 to get more accurate results

Additional details and impacted files
Files Coverage Δ
src/awkward/__init__.py 97.05% <100.00%> (+0.08%) ⬆️
src/awkward/_backends/backend.py 88.09% <ø> (ø)
src/awkward/_backends/cupy.py 66.66% <ø> (ø)
src/awkward/_backends/dispatch.py 92.85% <ø> (ø)
src/awkward/_backends/jax.py 100.00% <ø> (ø)
src/awkward/_backends/numpy.py 100.00% <ø> (ø)
src/awkward/_backends/typetracer.py 78.12% <ø> (ø)
src/awkward/_behavior.py 86.91% <ø> (ø)
src/awkward/_broadcasting.py 95.43% <ø> (ø)
src/awkward/_categorical.py 60.00% <100.00%> (+1.37%) ⬆️
... and 48 more

... and 212 files with indirect coverage changes

@agoose77
Copy link
Collaborator Author

agoose77 commented Nov 6, 2023

@henryiii have you come across a mechanism for scoping isort.required-imports to particular files?

@henryiii
Copy link
Member

henryiii commented Nov 6, 2023

You can disable I101 for subsets of files. Sadly, that drops everything, not just the isort addition. There will be a way to do it with PEP 723 if that gets implemented per file. You can also put a .ruff.toml in a subdirectory, I think.

Copy link
Member

@jpivarski jpivarski left a comment

Choose a reason for hiding this comment

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

If we're going to be touching all of these files, anyway, let's clean up some long-standing format issues.

  • GitHub website (dropping the "-1.0")
  • uniform placement of the LICENSE line
  • uniform vertical spacing in the first few lines
  • uniform placement of __all__ relative to imports.

Since the new from __future__ import annotations goes first, I put the __all__ after all imports. There's usually a few more assignments in that position, so it fits in, but it's always separated from them by at least a linefeed.

This includes touching the C++ code, since those files had inconsistent LICENSE messages, too. If you want to avoid triggering a new awkward-cpp right now, we can revert the last commit on the whole awkward-cpp directory.

Otherwise, I think this is ready to be merged.

agoose77 and others added 6 commits November 7, 2023 09:39
This is now not needed, and isort is handled by ruff
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.1.3 → v0.1.4](astral-sh/ruff-pre-commit@v0.1.3...v0.1.4)
- [github.com/python-jsonschema/check-jsonschema: 0.27.0 → 0.27.1](python-jsonschema/check-jsonschema@0.27.0...0.27.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@agoose77 agoose77 force-pushed the agoose77/chore-drop-isort-config branch from 6f3678c to 073ac8d Compare November 7, 2023 09:43
@agoose77
Copy link
Collaborator Author

agoose77 commented Nov 7, 2023

Although I'm loathed to touch the C++ again, we really want to avoid these things living for a long time. As such, I'm just going to merge! Thanks all!

@agoose77 agoose77 enabled auto-merge (squash) November 7, 2023 09:45
@agoose77 agoose77 merged commit 015a362 into main Nov 7, 2023
34 checks passed
@agoose77 agoose77 deleted the agoose77/chore-drop-isort-config branch November 7, 2023 09:55
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