-
-
Notifications
You must be signed in to change notification settings - Fork 873
Additional cleanup for python 3.9 #6758
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
Conversation
- 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
Coverage Results ✅
|
There was a problem hiding this 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 💯
src/sqlfluff/core/config/file.py
Outdated
|
||
# Explicitly rename so that mypy is happy re-exporting it for other | ||
# modules to use. | ||
from functools import cache as cache |
There was a problem hiding this comment.
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.
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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
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.
typing
collections forcollections.abc
__new__
functionsuper()
callsfunctools.lru_cache
usageLintingRecord
converted to aTypedDict
classAre 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 intest/fixtures/rules/std_rule_cases
..sql
/.yml
parser test cases intest/fixtures/dialects
(note YML files can be auto generated withtox -e generate-fixture-yml
).test/fixtures/linter/autofix
.Added appropriate documentation for the change.
Created GitHub issues for any relevant followup/future enhancements if appropriate.