-
-
Notifications
You must be signed in to change notification settings - Fork 873
Formatter Stub Types #6761
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
Formatter Stub Types #6761
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 pull request refines the formatter integration by replacing ambiguous Any types with a clearly defined FormatterInterface, improving type-safety and consistency across modules. Key changes include:
- Updated function signatures in the linter to use Optional[FormatterInterface].
- Added abstract methods to FormatterInterface in the formatter module.
- Modified the CLI formatter implementations to align with the new interface and updated type annotations.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/sqlfluff/core/linter/linter.py | Updated formatter type annotations and added a filename fallback |
src/sqlfluff/core/formatter.py | Introduced stub methods into FormatterInterface |
src/sqlfluff/cli/formatters.py | Adjusted type annotations in formatter method implementations |
formatter.dispatch_dialect_warning(parsed.config.get("dialect")) | ||
formatter.dispatch_dialect_warning( | ||
# The dialect property is the string, not the dialect object | ||
cast(str, parsed.config.get("dialect")) |
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.
The symbol 'cast' is used in dispatch_dialect_warning but no import statement for cast is present. Consider adding 'from typing import cast' to ensure type casting works as expected.
Copilot uses AI. Check for mistakes.
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.
@alanmcruickshank is this valid?
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.
Seems invalid given that cast
is imported on line 8.
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.
Seems to make sense. LGTM.
Related to the other python 3.8 clearups, I've been meaning to properly define the formatter class which is currently just an
Any
class. This defines the necessary stub methods in thelinter
module, which thecli
module simply implements.