-
-
Notifications
You must be signed in to change notification settings - Fork 873
Tighter typing of Rule configs #6750
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
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.
Pull Request Overview
This PR aims to remove the use of ambiguous "Any" types in Rule configs by introducing a more explicit ConfigInfo type, thereby ensuring tighter type safety and clearer configuration definitions.
- Removed Any from type hints in multiple rule bundles
- Introduced and adopted the new ConfigInfo TypedDict in core config files and plugins
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/sqlfluff/rules/structure/init.py | Replaced Any with ConfigInfo in get_configs_info |
src/sqlfluff/rules/references/init.py | Replaced Any with ConfigInfo in get_configs_info |
src/sqlfluff/rules/layout/init.py | Replaced Any with ConfigInfo in get_configs_info |
src/sqlfluff/rules/convention/init.py | Replaced Any with ConfigInfo in get_configs_info |
src/sqlfluff/rules/capitalisation/init.py | Replaced Any with ConfigInfo in get_configs_info |
src/sqlfluff/rules/ambiguous/init.py | Replaced Any with ConfigInfo in get_configs_info |
src/sqlfluff/rules/aliasing/init.py | Replaced Any with ConfigInfo in get_configs_info |
src/sqlfluff/core/rules/config_info.py | Introduced ConfigInfo TypedDict and updated get_config_info type hints |
src/sqlfluff/core/rules/base.py | Updated init type hints for config_info parameter |
src/sqlfluff/core/rules/init.py | Updated type hints for get_configs_info and exposed ConfigInfo |
src/sqlfluff/core/plugin/lib.py | Updated get_configs_info type hints |
plugins/sqlfluff-plugin-example/src/sqlfluff_plugin_example/init.py | Updated get_configs_info type hints and example config definitions |
Comments suppressed due to low confidence (2)
src/sqlfluff/core/rules/config_info.py:38
- Ensure compatibility with Python versions earlier than 3.11 since 'NotRequired' is available only in 3.11+. If supporting older versions, consider importing NotRequired from typing_extensions.
validation: NotRequired[List[bool | str | int] | range]
plugins/sqlfluff-plugin-example/src/sqlfluff_plugin_example/init.py:54
- Consider updating the definition to 'A list of columns to forbid' to improve grammatical accuracy.
"forbidden_columns": {"definition": "A list of column to forbid"},
""" | ||
|
||
definition: str | ||
validation: NotRequired[List[bool | str | int] | range] |
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.
NotRequired is Python 3.11+
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.
balls. Back to the drawing board...
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.
LGTM
We've had some
Any
types in the Rule configs for a while which I've been wanting to get rid of. This introduces more explicit typing for them and banishes some of some of the remainingAny
types.