Skip to content

Commit

Permalink
fix: rename modules that shadow python built-ins (#664)
Browse files Browse the repository at this point in the history
* fix: rename modules that shadow python built-ins

* fix: actually save the changes this time
  • Loading branch information
tconbeer authored Jan 24, 2025
1 parent 814f640 commit dcd48b3
Show file tree
Hide file tree
Showing 52 changed files with 119 additions and 146 deletions.
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.1
rev: v0.9.3
hooks:
- id: ruff-format
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.0
rev: v1.14.1
hooks:
- id: mypy
additional_dependencies:
Expand Down
30 changes: 0 additions & 30 deletions mypy.ini

This file was deleted.

40 changes: 20 additions & 20 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ pre-commit = { version = ">=4.0,<5", python = ">=3.9" }
snakeviz = "^2.1.1"

[tool.poetry.group.static.dependencies]
ruff = "^0.5"
mypy = "^1.11"
ruff = "^0.9.3"
mypy = "^1.14"

[tool.poetry.group.test.dependencies]
black = "^24"
Expand Down
8 changes: 4 additions & 4 deletions src/sqlfmt/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from sqlfmt.line import Line
from sqlfmt.node import Node, get_previous_token
from sqlfmt.rule import MAYBE_WHITESPACES, Rule
from sqlfmt.token import Token, TokenType
from sqlfmt.tokens import Token, TokenType

if TYPE_CHECKING:
from sqlfmt.analyzer import Analyzer
Expand All @@ -29,7 +29,7 @@ def raise_sqlfmt_bracket_error(
raise SqlfmtBracketError(
f"Encountered closing bracket '{raw_token}' at position"
f" {spos}, before matching opening bracket. Context:"
f" {source_string[spos:spos+50]}"
f" {source_string[spos : spos + 50]}"
)


Expand Down Expand Up @@ -193,7 +193,7 @@ def handle_ddl_as(
assert analyzer.rule_stack, (
"Internal Error! Open an issue. Could not parse DDL 'as' "
f"at pos {analyzer.pos}. Context: "
f"{source_string[analyzer.pos :analyzer.pos+50]}"
f"{source_string[analyzer.pos : analyzer.pos + 50]}"
)
analyzer.pop_rules()

Expand Down Expand Up @@ -228,7 +228,7 @@ def handle_closing_angle_bracket(
assert operator_match, (
"Internal Error! Open an issue. Could not parse closing bracket '>' "
f"at pos {analyzer.pos}. Context: "
f"{source_string[analyzer.pos :analyzer.pos+10]}"
f"{source_string[analyzer.pos : analyzer.pos + 10]}"
)
add_node_to_buffer(
analyzer=analyzer,
Expand Down
2 changes: 1 addition & 1 deletion src/sqlfmt/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def lex_one(self, source_string: str) -> None:
else:
raise SqlfmtParsingError(
f"Could not parse SQL at position {self.pos}:"
f" '{source_string[self.pos:self.pos+50].strip()}'"
f" '{source_string[self.pos : self.pos + 50].strip()}'"
)

def lex(self, source_string: str, eof_pos: int = -1) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/sqlfmt/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
from sqlfmt.analyzer import Analyzer
from sqlfmt.cache import Cache, check_cache, clear_cache, load_cache, write_cache
from sqlfmt.exception import SqlfmtEquivalenceError, SqlfmtError, SqlfmtUnicodeError
from sqlfmt.formatter import QueryFormatter
from sqlfmt.mode import Mode as Mode
from sqlfmt.query import Query
from sqlfmt.query_formatter import QueryFormatter
from sqlfmt.report import STDIN_PATH, Report, SqlFormatResult

T = TypeVar("T")
Expand Down
2 changes: 1 addition & 1 deletion src/sqlfmt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from sqlfmt.mode import Mode


@click.command() # type: ignore
@click.command()
@click.version_option(package_name="shandy-sqlfmt")
@click.option(
"--check",
Expand Down
2 changes: 1 addition & 1 deletion src/sqlfmt/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import ClassVar, Iterator, Optional, Tuple

from sqlfmt.node import Node
from sqlfmt.token import Token, TokenType
from sqlfmt.tokens import Token, TokenType


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion src/sqlfmt/jinjafmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def _remove_trailing_comma(self) -> None:
trailing_comma_match = trailing_comma_prog.search(source_string)
if trailing_comma_match:
idx = trailing_comma_match.span()[0]
processed_string = f"{source_string[:idx]}{source_string[idx+1:]}"
processed_string = f"{source_string[:idx]}{source_string[idx + 1 :]}"
self.code = processed_string

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion src/sqlfmt/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from sqlfmt.comment import Comment
from sqlfmt.node import Node, get_previous_token
from sqlfmt.token import Token, TokenType
from sqlfmt.tokens import Token, TokenType


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion src/sqlfmt/node.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dataclasses import dataclass, field
from typing import List, Optional, Tuple

from sqlfmt.token import Token, TokenType
from sqlfmt.tokens import Token, TokenType


def get_previous_token(prev_node: Optional["Node"]) -> Tuple[Optional[Token], bool]:
Expand Down
2 changes: 1 addition & 1 deletion src/sqlfmt/node_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sqlfmt.exception import SqlfmtBracketError
from sqlfmt.line import Line
from sqlfmt.node import Node, get_previous_token
from sqlfmt.token import Token, TokenType
from sqlfmt.tokens import Token, TokenType


class NodeManager:
Expand Down
8 changes: 4 additions & 4 deletions src/sqlfmt/operator_precedence.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Callable, List

from sqlfmt.node import Node
from sqlfmt.token import TokenType
from sqlfmt.tokens import TokenType


class OperatorPrecedence(IntEnum):
Expand Down Expand Up @@ -37,9 +37,9 @@ def tiers() -> List["OperatorPrecedence"]:

@classmethod
def from_node(cls, node: Node) -> "OperatorPrecedence":
assert (
node.is_operator
), f"Internal error! {node} is not an operator. Please open an issue"
assert node.is_operator, (
f"Internal error! {node} is not an operator. Please open an issue"
)
return cls._function_lookup(token_type=node.token.type)(node)

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion src/sqlfmt/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from sqlfmt.line import Line
from sqlfmt.node import Node
from sqlfmt.token import Token
from sqlfmt.tokens import Token


@dataclass
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/sqlfmt/rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from sqlfmt.rules.jinja import JINJA as JINJA # noqa
from sqlfmt.rules.unsupported import UNSUPPORTED as UNSUPPORTED
from sqlfmt.rules.warehouse import WAREHOUSE as WAREHOUSE
from sqlfmt.token import TokenType
from sqlfmt.tokens import TokenType

MAIN = [
*CORE,
Expand Down
2 changes: 1 addition & 1 deletion src/sqlfmt/rules/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sqlfmt.rule import Rule
from sqlfmt.rules.common import CREATE_CLONABLE, group
from sqlfmt.rules.core import CORE
from sqlfmt.token import TokenType
from sqlfmt.tokens import TokenType

CLONE = [
*CORE,
Expand Down
2 changes: 1 addition & 1 deletion src/sqlfmt/rules/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sqlfmt.rule import Rule
from sqlfmt.rules.common import EOL, NEWLINE, SQL_COMMENT, SQL_QUOTED_EXP, group
from sqlfmt.rules.jinja import JINJA
from sqlfmt.token import TokenType
from sqlfmt.tokens import TokenType

ALWAYS = [
Rule(
Expand Down
2 changes: 1 addition & 1 deletion src/sqlfmt/rules/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sqlfmt.rule import Rule
from sqlfmt.rules.common import ALTER_DROP_FUNCTION, CREATE_FUNCTION, group
from sqlfmt.rules.core import CORE
from sqlfmt.token import TokenType
from sqlfmt.tokens import TokenType

FUNCTION = [
*CORE,
Expand Down
2 changes: 1 addition & 1 deletion src/sqlfmt/rules/grant.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sqlfmt.rule import Rule
from sqlfmt.rules.common import group
from sqlfmt.rules.core import CORE
from sqlfmt.token import TokenType
from sqlfmt.tokens import TokenType

GRANT = [
*CORE,
Expand Down
2 changes: 1 addition & 1 deletion src/sqlfmt/rules/jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from sqlfmt import actions
from sqlfmt.rule import Rule
from sqlfmt.rules.common import NEWLINE, group
from sqlfmt.token import TokenType
from sqlfmt.tokens import TokenType

JINJA_SHARED_PATTERNS = {
"set": r"\{%-?\s*set\s+[^=]+?-?%\}",
Expand Down
2 changes: 1 addition & 1 deletion src/sqlfmt/rules/unsupported.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sqlfmt.rule import Rule
from sqlfmt.rules.common import NEWLINE, group
from sqlfmt.rules.core import ALWAYS
from sqlfmt.token import TokenType
from sqlfmt.tokens import TokenType

UNSUPPORTED = [
*ALWAYS,
Expand Down
2 changes: 1 addition & 1 deletion src/sqlfmt/rules/warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sqlfmt.rule import Rule
from sqlfmt.rules.common import ALTER_WAREHOUSE, CREATE_WAREHOUSE, group
from sqlfmt.rules.core import CORE
from sqlfmt.token import TokenType
from sqlfmt.tokens import TokenType

WAREHOUSE = [
*CORE,
Expand Down
6 changes: 3 additions & 3 deletions src/sqlfmt/splitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def maybe_split(self, line: Line) -> List[Line]:
new_line, comments = self.split_at_index(
line, head, i, comments, no_tail=True
)
assert (
not comments
), "Comments must be empty here or we'll drop them"
assert not comments, (
"Comments must be empty here or we'll drop them"
)
new_lines.append(new_line)
return new_lines
elif (
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/sqlfmt_primer/primer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import click
from git.repo import Repo
from platformdirs import user_cache_dir

from sqlfmt.api import get_matching_paths, initialize_progress_bar, run
from sqlfmt.cache import get_cache_file
from sqlfmt.mode import Mode
Expand Down
3 changes: 1 addition & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import pytest
from click.testing import CliRunner

from sqlfmt.analyzer import Analyzer
from sqlfmt.mode import Mode

from tests.util import copy_test_data_to_tmp

# make tests module importable
Expand All @@ -21,7 +21,6 @@ def pytest_sessionstart(session: pytest.Session) -> None:
before performing collection and entering the run test loop.
"""
from sqlfmt.cache import clear_cache

from tests.util import delete_results_dir

delete_results_dir()
Expand Down
1 change: 1 addition & 0 deletions tests/functional_tests/test_end_to_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest
from click.testing import CliRunner

from sqlfmt.cli import sqlfmt as sqlfmt_main


Expand Down
2 changes: 1 addition & 1 deletion tests/functional_tests/test_general_formatting.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from sqlfmt.api import format_string
from sqlfmt.mode import Mode

from tests.util import check_formatting, read_test_data


Expand Down
Loading

0 comments on commit dcd48b3

Please sign in to comment.