Skip to content

Commit 5ebfe26

Browse files
Update CI and support for currently supported Python versions (#63)
* Update CI and support for currently supported Python versions Fixes #57 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * chore: remove unused imports Signed-off-by: Mike Fiedler <[email protected]> --------- Signed-off-by: Mike Fiedler <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 469878a commit 5ebfe26

File tree

9 files changed

+19
-28
lines changed

9 files changed

+19
-28
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
14+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
1515
steps:
1616
- uses: actions/checkout@v4
1717
with:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ repos:
2828
rev: v3.19.1
2929
hooks:
3030
- id: pyupgrade
31-
args: [--py38-plus]
31+
args: [--py39-plus]
3232
- repo: https://github.com/jendrikseipp/vulture
3333
rev: 'v2.14'
3434
hooks:

flake8_sqlalchemy/checkers/_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import ast
2-
from typing import Any, List, Optional
2+
from typing import Any, Optional
33

44
from ..issue import Issue
55

@@ -13,5 +13,5 @@ def get_call_name(node: ast.Call) -> Optional[str]:
1313
return node.func.id
1414
return None
1515

16-
def run(self, node: Any) -> List[Issue]: # TODO correct type hint
16+
def run(self, node: Any) -> list[Issue]: # TODO correct type hint
1717
raise NotImplementedError

flake8_sqlalchemy/checkers/column_comment.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Checks that Columns have comments."""
22

33
import ast
4-
from typing import List
54

65
from ..issue import Issue
76
from ._base import Checker
@@ -13,13 +12,13 @@ class SQA200(Issue):
1312

1413

1514
class ColumnCommentChecker(Checker):
16-
def run(self, node: ast.Call) -> List[Issue]:
15+
def run(self, node: ast.Call) -> list[Issue]:
1716
"""
1817
Checks if a column is missing a `comment` keyword argument on:
1918
- `sqlalchemy.Column`
2019
- `sqlalchemy.orm.mapped_column`
2120
"""
22-
issues: List[Issue] = []
21+
issues: list[Issue] = []
2322

2423
if self.is_column(node) and not self.has_comment(node):
2524
issues.append(SQA200(node.lineno, node.col_offset))

flake8_sqlalchemy/checkers/import_alias.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Checks that the sqlalchemy import is aliased as `sa` or `db`."""
22

33
import ast
4-
from typing import List
54

65
from ..issue import Issue
76
from ._base import Checker
@@ -13,12 +12,12 @@ class SQA100(Issue):
1312

1413

1514
class ImportAliasChecker(Checker):
16-
def run(self, node: ast.Import) -> List[Issue]:
15+
def run(self, node: ast.Import) -> list[Issue]:
1716
"""
1817
Checks if the `sqlalchemy` module is imported with an alias
1918
other than `sa` or `db`.
2019
"""
21-
issues: List[Issue] = []
20+
issues: list[Issue] = []
2221

2322
for alias in node.names:
2423
if alias.name == "sqlalchemy" and alias.asname not in (None, "sa", "db"):

flake8_sqlalchemy/checkers/relationship_backref_checker.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Checker for detecting `backref` usage in SQLAlchemy relationships."""
22

33
import ast
4-
from typing import List
54

65
from ..issue import Issue
76
from ._base import Checker
@@ -13,12 +12,12 @@ class SQA300(Issue):
1312

1413

1514
class RelationshipBackrefChecker(Checker):
16-
def run(self, node: ast.Call) -> List[Issue]:
15+
def run(self, node: ast.Call) -> list[Issue]:
1716
"""
1817
Checks if a relationship() call uses `backref` and suggests
1918
`back_populates` instead.
2019
"""
21-
issues: List[Issue] = []
20+
issues: list[Issue] = []
2221

2322
if self.is_relationship_with_backref(node):
2423
issues.append(SQA300(node.lineno, node.col_offset))

flake8_sqlalchemy/plugin.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import ast
22
import importlib.metadata
3-
from typing import Any, Dict, Generator, List, Tuple, Type
3+
from collections.abc import Generator
4+
from typing import Any
45

56
from .checkers import (
67
ColumnCommentChecker,
@@ -11,7 +12,7 @@
1112

1213

1314
class Visitor(ast.NodeVisitor):
14-
checkers: Dict[str, List[Any]] = {
15+
checkers: dict[str, list[Any]] = {
1516
"Call": [
1617
ColumnCommentChecker(),
1718
RelationshipBackrefChecker(),
@@ -22,7 +23,7 @@ class Visitor(ast.NodeVisitor):
2223
}
2324

2425
def __init__(self) -> None:
25-
self.issues: List[Issue] = []
26+
self.issues: list[Issue] = []
2627

2728
def capture_issues_from(self, visitor: str, node: ast.AST) -> None:
2829
for checker in self.checkers[visitor]:
@@ -45,7 +46,7 @@ class Plugin:
4546
def __init__(self, tree: ast.AST) -> None:
4647
self._tree = tree
4748

48-
def run(self) -> Generator[Tuple[int, int, str, Type[Any]], None, None]:
49+
def run(self) -> Generator[tuple[int, int, str, type[Any]], None, None]:
4950
visitor = Visitor()
5051
visitor.visit(self._tree)
5152

pyproject.toml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ classifiers = [
2121
"Natural Language :: English",
2222
"Operating System :: OS Independent",
2323
"Programming Language :: Python :: 3",
24-
"Programming Language :: Python :: 3.8",
2524
"Programming Language :: Python :: 3.9",
2625
"Programming Language :: Python :: 3.10",
2726
"Programming Language :: Python :: 3.11",
27+
"Programming Language :: Python :: 3.12",
28+
"Programming Language :: Python :: 3.13",
2829
"Topic :: Software Development :: Libraries :: Python Modules",
2930
"Topic :: Software Development :: Quality Assurance",
3031
"Topic :: Software Development :: Testing",
@@ -37,7 +38,7 @@ classifiers = [
3738
"SQA" = "flake8_sqlalchemy:Plugin"
3839

3940
[tool.poetry.dependencies]
40-
python = "^3.8.1"
41+
python = "^3.9.0"
4142
flake8 = ">=6,<8"
4243

4344
[tool.poetry.group.dev.dependencies]
@@ -47,13 +48,6 @@ pytest = ">=7.3,<9.0"
4748
pytest-cov = ">=4,<6"
4849
sqlalchemy = "^2.0"
4950

50-
# greenlet is a dependency of SQLAlchemy, unrelease Python 3.12-compatible
51-
# remove this once greenlet 3.0.0 is released.
52-
greenlet = [
53-
{ version = "^3.0.0rc1", python = "^3.12.0rc1" },
54-
{ version = "<3.0.0a0", python = "<3.12" },
55-
]
56-
5751
[tool.coverage.run]
5852
branch = true
5953
source = ["flake8_sqlalchemy"]

tests/conftest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Testing configs, utilities, and fixtures for the tests package."""
22

33
import ast
4-
from typing import Set
54

65
import pytest
76

@@ -10,7 +9,7 @@
109

1110
class Helpers:
1211
@staticmethod
13-
def results(s: str) -> Set[str]:
12+
def results(s: str) -> set[str]:
1413
tree = ast.parse(s)
1514
plugin = Plugin(tree)
1615
return {f"{line}:{col + 1} {msg}" for line, col, msg, _ in plugin.run()}

0 commit comments

Comments
 (0)