Skip to content

Conversation

alanmcruickshank
Copy link
Member

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 the linter module, which the cli module simply implements.

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 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"))
Copy link
Preview

Copilot AI Mar 30, 2025

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

@alanmcruickshank is this valid?

Copy link
Contributor

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.

Copy link
Contributor

github-actions bot commented Mar 30, 2025

Coverage Results ✅

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

249 files skipped due to complete coverage.

Copy link
Contributor

@keraion keraion left a 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.

@WittierDinosaur WittierDinosaur added this pull request to the merge queue Apr 1, 2025
Merged via the queue into main with commit e490ed5 Apr 1, 2025
30 checks passed
@WittierDinosaur WittierDinosaur deleted the ac/formatter_types branch April 1, 2025 11:05
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.

3 participants