Skip to content

Commit

Permalink
Mypy checks + fixes (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
MissingNO57 authored Dec 16, 2022
1 parent 8ed13fb commit a020f5d
Show file tree
Hide file tree
Showing 29 changed files with 109 additions and 208 deletions.
28 changes: 14 additions & 14 deletions Pipfile.lock

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"prepack": "rm -rf dist && npm build",
"test": "jest",
"codegen": "subql codegen",
"pylint-checks": "black --check --verbose src/genesis tests && isort --check-only src/genesis tests && flake8 src/genesis tests",
"pylint-checks": "black --check --verbose src/genesis tests && isort --check-only src/genesis tests && flake8 src/genesis tests && mypy src/genesis --disable-error-code import && mypy tests --disable-error-code import",
"pylint": "black src/genesis tests && isort src/genesis tests && flake8 src/genesis tests && mypy src/genesis --disable-error-code import && mypy tests --disable-error-code import && pylint src/genesis tests",
"start:docker": "docker-compose pull && docker-compose up --remove-orphans",
"start:tracing": "docker-compose -f docker-compose.tracing.yml pull && docker-compose -f docker-compose.tracing.yml up --remove-orphans",
Expand Down
9 changes: 3 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
[flake8]
paths=cosmpy
paths=src, tests
copyright-check = True
select = B,C,D,E,F,I,W,
exclude=.md,
vulture_whitelist.py
cosmpy/protos
tests/unit/test_clients/test_cosmos_ledger.py
tests/integration/
exclude=.md
ignore = D403, E501, W503, F403, E203
docstring_style=sphinx
strictness=short
Expand All @@ -23,6 +19,7 @@ strictness=short
python_version = 3.9
strict_optional = True
exclude = vulture_whitelist.py
namespace_packages = False

[mypy-google.*]
ignore_missing_imports = True
Expand Down
13 changes: 8 additions & 5 deletions src/genesis/db/table_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@

def table_exists(db_conn: Connection, table: str) -> bool:
with db_conn.cursor() as db:
return db.execute(
res_db_execute = db.execute(
f"""
SELECT EXISTS (
SELECT FROM pg_tables WHERE
schemaname = 'app' AND
tablename = '{table}'
)
"""
).fetchone()[0]
).fetchone()

assert res_db_execute is not None

return res_db_execute[0]


class TableManager:
Expand All @@ -29,14 +33,13 @@ def __init__(self, db_conn: Connection):
self._db_conn = db_conn

@classmethod
@property
def column_names(cls) -> Generator[str, Any, None]:
def get_column_names(cls) -> Generator[str, Any, None]:
return (name for name, _ in cls._columns)

@classmethod
def select_query(cls) -> str:
return f"""
SELECT {",".join(cls.column_names)} FROM {cls._table}
SELECT {",".join(cls.get_column_names())} FROM {cls._table}
"""

def _ensure_table(self):
Expand Down
Loading

0 comments on commit a020f5d

Please sign in to comment.