Skip to content

Commit

Permalink
Merge pull request #5 from mixxorz/chore/pyright
Browse files Browse the repository at this point in the history
Add pyright type checking
  • Loading branch information
mixxorz authored Aug 14, 2022
2 parents 3393f2e + 06a0e60 commit 530a951
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ repos:
rev: 22.6.0
hooks:
- id: black
- repo: local
hooks:
- id: pyright
name: pyright
entry: poetry run npx [email protected]
language: node
pass_filenames: false
types: [python]
3 changes: 3 additions & 0 deletions dslr/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ def get_snapshots() -> List[Snapshot]:
# Find the snapshot databases
result = exec_sql("SELECT datname FROM pg_database WHERE datname LIKE 'dslr_%'")

if not result:
raise RuntimeError("Did not get results from database.")

snapshot_dbnames = sorted([row[0] for row in result])

# Parse the name into a Snapshot
Expand Down
1 change: 1 addition & 0 deletions dslr/pg_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Any, List, Optional, Tuple

import psycopg2
import psycopg2.extensions

from dslr.console import console

Expand Down
2 changes: 1 addition & 1 deletion dslr/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def exec_shell(*cmd: str) -> Result:


def exec_sql(
sql: Union[sql.SQL, str], data: Optional[List[Any]] = None
sql: Union[sql.Composed, str], data: Optional[List[Any]] = None
) -> Optional[List[Tuple[Any, ...]]]:
"""
Executes a SQL query.
Expand Down
7 changes: 6 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ envlist =
flake8
black
isort
pyright
py37
py38
py39
Expand All @@ -14,7 +15,7 @@ python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310, flake8, black, isort
3.10: py310, flake8, black, isort, pyright

[testenv]
deps = psycopg2-binary
Expand All @@ -29,6 +30,10 @@ commands = flake8
deps = black >=22.6.0, <23.0.0
commands = black --check ./

[testenv:pyright]
deps = pyright == 1.1.266
commands = pyright

[testenv:isort]
deps = isort >= 5.10.1, <6.0.0
commands = isort dslr tests --check-only --diff

0 comments on commit 530a951

Please sign in to comment.