Skip to content

Commit

Permalink
ci(ruff): Automated lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Jul 1, 2023
1 parent a81172e commit 5d7a3c3
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@

def linkcode_resolve(
domain: str, info: t.Dict[str, str]
) -> t.Union[None, str]: # NOQA: C901
) -> t.Union[None, str]:
"""
Determine the URL corresponding to Python object
Expand Down
1 change: 0 additions & 1 deletion examples/01_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import pprint

from sqlalchemy.sql.expression import func

from unihan_db import bootstrap
from unihan_db.tables import Unhn

Expand Down
18 changes: 7 additions & 11 deletions src/unihan_db/bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import logging
import sys
from datetime import datetime
import typing as t
from sqlalchemy import create_engine, event
from datetime import datetime

import sqlalchemy
from sqlalchemy import create_engine, event
from sqlalchemy.orm import Session, class_mapper, scoped_session, sessionmaker
from sqlalchemy.orm.decl_api import registry
from sqlalchemy.orm.scoping import ScopedSession

from unihan_etl import core as unihan
from unihan_etl.types import UntypedUnihanData
from unihan_etl.util import merge_dict
Expand Down Expand Up @@ -135,13 +137,10 @@ def setup_logger(
def is_bootstrapped(metadata: sqlalchemy.MetaData) -> bool:
"""Return True if cihai is correctly bootstrapped."""
fields = UNIHAN_FIELDS + DEFAULT_FIELDS
if TABLE_NAME in metadata.tables.keys():
if TABLE_NAME in metadata.tables:
table = metadata.tables[TABLE_NAME]

if set(fields) == {c.name for c in table.columns}:
return True
else:
return False
return set(fields) == {c.name for c in table.columns}
else:
return False

Expand Down Expand Up @@ -224,10 +223,7 @@ def _get_key_value(c: str) -> t.Any:

_found: t.Set[t.Any]

if found is None:
_found = set()
else:
_found = found
_found = set() if found is None else found

_mapper = class_mapper(obj.__class__)
columns = [column.key for column in _mapper.columns]
Expand Down
3 changes: 2 additions & 1 deletion src/unihan_db/importer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import typing as t

from unihan_db.tables import (
Unhn,
UnhnLocation,
Expand Down Expand Up @@ -58,7 +59,7 @@ def import_char(
t.Dict[str, object],
],
],
) -> None: # NOQA: C901
) -> None:
if "kDefinition" in char:
for kd in char["kDefinition"]:
c.kDefinition.append(kDefinition(definition=kd))
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import pathlib
import typing as t
import zipfile
import sqlalchemy

import pytest
from sqlalchemy.orm import sessionmaker, scoped_session
import sqlalchemy
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.orm.scoping import ScopedSession
from unihan_db.bootstrap import UNIHAN_FILES

Expand Down
6 changes: 3 additions & 3 deletions tests/test_bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import pathlib
from sqlalchemy.orm import Session
from unihan_db import bootstrap
from unihan_db.tables import Base, Unhn
import typing as t

import sqlalchemy
from sqlalchemy.orm import Session
from unihan_db import bootstrap
from unihan_db.tables import Base, Unhn


class UnihanOptions(t.TypedDict):
Expand Down

0 comments on commit 5d7a3c3

Please sign in to comment.