Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pyright type checking #5

Merged
merged 4 commits into from
Aug 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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