Skip to content

Conversation

alanmcruickshank
Copy link
Member

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 remaining Any types.

Copy link

@Copilot Copilot AI left a 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]
Copy link
Contributor

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+

Copy link
Member Author

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...

Copy link
Contributor

github-actions bot commented Mar 26, 2025

Coverage Results ✅

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

248 files skipped due to complete coverage.

Copy link
Contributor

@WittierDinosaur WittierDinosaur left a comment

Choose a reason for hiding this comment

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

LGTM

@WittierDinosaur WittierDinosaur added this pull request to the merge queue Mar 29, 2025
Merged via the queue into main with commit ed6f4a3 Mar 29, 2025
30 checks passed
@WittierDinosaur WittierDinosaur deleted the ac/config_types branch March 29, 2025 13:50
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