Skip to content

Commit

Permalink
fix: Linting.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanCardin committed Aug 30, 2024
1 parent 32b8f62 commit dd571ad
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 49 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
poetry run pip install 'pytest-asyncio~=${{ matrix.pytest-asyncio-version }}'
- name: Run linters
if: ${{ matrix.python-version != '3.8' }}
run: poetry run make lint

- name: Run tests
Expand Down
64 changes: 32 additions & 32 deletions poetry.lock

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

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ sqlalchemy = "*"
[tool.poetry.dev-dependencies]
asyncpg = "*"
black = {version = "22.3.0", python = ">=3.6.2"}
coverage = {version = ">=6.4.4", extras = ["toml"], python = ">=3.7"}
coverage = {version = ">=6.4.4", extras = ["toml"]}
greenlet = ">=3.0"
mypy = {version = ">=0.900", python = ">=3.5"}
mypy = {version = ">=1.11", python = ">=3.8"}
psycopg2-binary = "*"
pytest = {version = ">=6.2"}
pytest-asyncio = "*"
pytest-mock-resources = {version = ">=2.6.3", extras = ["docker"], python = ">=3.7"}
ruff = {version = '0.0.269', python = ">3.7"}
pytest-mock-resources = {version = ">=2.6.3", extras = ["docker"]}
ruff = {version = '0.0.269'}
sqlalchemy = {version = ">=1.4", extras = ["asyncio"]}
types-dataclasses = "^0.1.7"

Expand Down
2 changes: 1 addition & 1 deletion src/pytest_alembic/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def run_task(self, fn, **kwargs):
except ImportError: # pragma: no cover
AsyncEngine = None # noqa: N806

if AsyncEngine and isinstance(self.connection, AsyncEngine):
if AsyncEngine and isinstance(self.connection, AsyncEngine): # type: ignore[truthy-function]
import asyncio

async def run(engine):
Expand Down
2 changes: 1 addition & 1 deletion src/pytest_alembic/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def revision_range(self, current_revision: str, dest_revision: str) -> List[str]
def revision_window(self, current_revision: str, dest_revision: str) -> List[Tuple[str, str]]:
revision_range = self.revision_range(current_revision, dest_revision)
return list(
zip( # type: ignore[arg-type]
zip(
*(
collections.deque(itertools.islice(it, i), 0) or it
for i, it in enumerate(itertools.tee(revision_range, 2))
Expand Down
2 changes: 1 addition & 1 deletion src/pytest_alembic/plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def pytest_collect_file(self, file_path, path, parent): # type: ignore[misc] #

else:

def pytest_collect_file(self, path, parent): # type: ignore[misc]
def pytest_collect_file(self, path, parent):
if self.should_register(Path(path)):
return TestCollector.from_parent(parent, fspath=path)
return None
Expand Down
20 changes: 10 additions & 10 deletions src/pytest_alembic/runner.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
from __future__ import annotations

import contextlib
import functools
from dataclasses import dataclass
from typing import Dict, List, Optional, Union
from typing import TYPE_CHECKING

import alembic.command
import alembic.migration
import alembic.util
from alembic.script.revision import RevisionMap

from pytest_alembic.config import Config
from pytest_alembic.executor import CommandExecutor, ConnectionExecutor
from pytest_alembic.history import AlembicHistory
from pytest_alembic.revision_data import RevisionData

if TYPE_CHECKING:
from pytest_alembic.config import Config


@contextlib.contextmanager
def runner(config: Config, engine=None):
Expand Down Expand Up @@ -60,7 +64,7 @@ def from_config(
)

@property
def heads(self) -> List[str]:
def heads(self) -> list[str]:
"""Get the list of revision heads.
Result is cached for the lifetime of the `MigrationContext`.
Expand Down Expand Up @@ -190,9 +194,7 @@ def migrate_up_before(self, revision):
preceeding_revision = self.history.previous_revision(revision)
return self.managed_upgrade(preceeding_revision)

def migrate_up_to(
self, revision, *, current: Optional[str] = None, return_current: bool = True
):
def migrate_up_to(self, revision, *, current: str | None = None, return_current: bool = True):
"""Migrate up to, and including the given `revision`."""
return self.managed_upgrade(revision, current=current, return_current=return_current)

Expand All @@ -210,9 +212,7 @@ def migrate_down_before(self, revision):
next_revision = self.history.next_revision(revision)
return self.migrate_down_to(next_revision)

def migrate_down_to(
self, revision, *, current: Optional[str] = None, return_current: bool = True
):
def migrate_down_to(self, revision, *, current: str | None = None, return_current: bool = True):
"""Migrate down to, and including the given `revision`."""
self.history.validate_revision(revision)
self.managed_downgrade(revision, current=current, return_current=return_current)
Expand All @@ -236,7 +236,7 @@ def roundtrip_next_revision(self):
return self.migrate_up_one()
return None

def insert_into(self, table: Optional[str], data: Union[Dict, List] = None, revision=None):
def insert_into(self, table: str | None, data: dict | list | None = None, revision=None):
"""Insert data into a given table.
Args:
Expand Down

0 comments on commit dd571ad

Please sign in to comment.