Skip to content

Conversation

keraion
Copy link
Contributor

@keraion keraion commented Mar 29, 2025

Brief summary of the change made

I found some additional opportunities with dropping python 3.8 and updating things that would likely need to be touched in October 2025.

  • Migrate away from deprecated typing collections for collections.abc
  • fix missed PEP 585 typing hints
  • cleanup some __new__ function super() calls
  • remove pre-3.9 functools.lru_cache usage
  • LintingRecord converted to a TypedDict class
  • simplified some comprehensions

Are there any other side effects of this change that we should be aware of?

None, this should functionally be the same.

Pull Request checklist

  • Please confirm you have completed any of the necessary steps below.

  • Included test cases to demonstrate any code changes, which may be one or more of the following:

    • .yml rule test cases in test/fixtures/rules/std_rule_cases.
    • .sql/.yml parser test cases in test/fixtures/dialects (note YML files can be auto generated with tox -e generate-fixture-yml).
    • Full autofix test cases in test/fixtures/linter/autofix.
    • Other.
  • Added appropriate documentation for the change.

  • Created GitHub issues for any relevant followup/future enhancements if appropriate.

- Migrate away from deprecated typing collections for collections.abc
- fix missed PEP 585 typing hints
- cleanup some __new__ functions' super() calls
- remove pre-3.9 lru_cache usage
- LintingRecord converted to a TypedDict class
- simplified some comprehensions
Copy link
Contributor

github-actions bot commented Mar 29, 2025

Coverage Results ✅

Name    Stmts   Miss  Cover   Missing
-------------------------------------
TOTAL   19534      0   100%

248 files skipped due to complete coverage.

Copy link
Member

@alanmcruickshank alanmcruickshank left a comment

Choose a reason for hiding this comment

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

Nice. I think we can further simplify the cache thing, but not re-exporting, and just importing directly from functools in the places that need it.

Otherwise this looks great 💯

Comment on lines 15 to 18

# Explicitly rename so that mypy is happy re-exporting it for other
# modules to use.
from functools import cache as cache
Copy link
Member

Choose a reason for hiding this comment

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

Now that we're not doing the version check on python and then importing it differently, I don't think we should re-export cache here, we should just import it directly from functools in whichever modules are using it.

Comment on lines +21 to +29
class LintingRecord(TypedDict):
"""A class to store the linted file statistics."""

filepath: str
violations: list[SerializedObject]
# Things like file length
statistics: dict[str, int]
# Raw timings, in seconds, for both rules and steps
timings: dict[str, float]
Copy link
Member

Choose a reason for hiding this comment

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

Nice 👍

@alanmcruickshank alanmcruickshank added this pull request to the merge queue Mar 30, 2025
Merged via the queue into main with commit 308dcca Mar 30, 2025
30 checks passed
@alanmcruickshank alanmcruickshank deleted the more_py39_cleanup branch March 30, 2025 09:34
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