Skip to content

Commit b4c6c01

Browse files
committed
Fix miscellaneous issues
1 parent bdbd404 commit b4c6c01

File tree

7 files changed

+27
-12
lines changed

7 files changed

+27
-12
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ classifiers = [
3333
"Typing :: Typed"
3434
]
3535
dependencies = [
36-
"json_strong_typing >= 0.4.1",
37-
"certifi >= 2025.10.5; python_version<'3.10'",
36+
"json_strong_typing >= 0.4.2",
37+
"certifi >= 2025.11.12; python_version<'3.10'",
3838
"truststore >= 0.10; python_version>='3.10'",
3939
"typing_extensions >= 4.15; python_version < '3.12'"
4040
]

pysqlsync/base.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from .model.data_types import SqlJsonType, SqlVariableCharacterType
2929
from .model.id_types import LocalId, QualifiedId, SupportsQualifiedId
3030
from .python_types import dataclass_to_code, module_to_code
31+
from .util.typing import override
3132

3233
D = TypeVar("D", bound=DataclassInstance)
3334
E = TypeVar("E", bound=enum.Enum)
@@ -515,6 +516,12 @@ async def close(self) -> None: ...
515516

516517

517518
class RecordTransformer:
519+
@abc.abstractmethod
520+
def is_identity(self) -> bool:
521+
"True if the transformer does nothing."
522+
523+
...
524+
518525
@abc.abstractmethod
519526
async def get(self, records: Iterable[RecordType]) -> Optional[Callable[[Any], Any]]:
520527
"""
@@ -537,6 +544,10 @@ def __init__(
537544
) -> None:
538545
self.fn = fn
539546

547+
@override
548+
def is_identity(self) -> bool:
549+
return self.fn is None
550+
540551
async def get(self, records: Iterable[RecordType]) -> Optional[Callable[[Any], Any]]:
541552
return self.fn
542553

@@ -559,6 +570,10 @@ def __init__(
559570
self.generator = generator
560571
self.index = index
561572

573+
@override
574+
def is_identity(self) -> bool:
575+
return False
576+
562577
async def _merge_lookup_table(self, values: set[str]) -> dict[str, int]:
563578
"Merges new values into a lookup table and returns the entire updated table."
564579

@@ -747,7 +762,7 @@ def to_data_source(records: RecordSource) -> DataSource:
747762

748763
if isinstance(records, Iterable):
749764
return IterableDataSource(records)
750-
elif isinstance(records, AsyncIterable):
765+
elif isinstance(records, AsyncIterable): # pyright: ignore[reportUnnecessaryIsInstance]
751766
return AsyncIterableDataSource(records)
752767
else:
753768
raise TypeError("expected: `Iterable` or `AsyncIterable` of records")
@@ -1084,7 +1099,7 @@ async def _generate_records(
10841099
transformer = self._get_transformer(table, generator, index, field_type, field_name)
10851100
transformers.append(transformer)
10861101

1087-
if all(transformer is None for transformer in transformers):
1102+
if all(transformer.is_identity() for transformer in transformers):
10881103
if len(indices) == len(field_types):
10891104
return source
10901105
else:
@@ -1194,7 +1209,7 @@ def _module_or_list(module: Optional[types.ModuleType], modules: Optional[list[t
11941209
raise TypeError("disallowed: both parameters `module` and `modules`")
11951210

11961211
if modules is not None:
1197-
if not isinstance(modules, list):
1212+
if not isinstance(modules, list): # pyright: ignore[reportUnnecessaryIsInstance]
11981213
raise TypeError("expected: list of modules for parameter `modules`")
11991214
entity_modules = modules
12001215
elif module is not None:

pysqlsync/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ConnectionSSLMode(enum.Enum):
4545
def create_context(ssl_mode: ConnectionSSLMode) -> Optional[ssl.SSLContext]:
4646
"Creates an SSL context to pass to a database connection object."
4747

48-
if ssl_mode is None or ssl_mode is ConnectionSSLMode.disable:
48+
if ssl_mode is ConnectionSSLMode.disable:
4949
return None
5050
elif ssl_mode is ConnectionSSLMode.prefer or ssl_mode is ConnectionSSLMode.allow or ssl_mode is ConnectionSSLMode.require:
5151
ctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)

pysqlsync/formation/object_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class StatementList(list[str]):
2121
def append(self, __object: Optional[str]) -> None:
2222
if __object is None:
2323
return
24-
if isinstance(__object, str) and not __object.strip():
24+
if isinstance(__object, str) and not __object.strip(): # pyright: ignore[reportUnnecessaryIsInstance]
2525
raise ValueError("empty statement")
2626
return super().append(__object)
2727

pysqlsync/formation/py_to_sql.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ class DataclassConverterOptions:
285285
foreign_constraints: bool = True
286286
check_constraints: bool = True
287287
initialize_tables: bool = False
288-
substitutions: dict[TypeLike, SqlDataType] = dataclasses.field(default_factory=dict)
288+
substitutions: dict[TypeLike, SqlDataType] = dataclasses.field(default_factory=dict[TypeLike, SqlDataType])
289289
factory: ObjectFactory = dataclasses.field(default_factory=ObjectFactory)
290290
skip_annotations: tuple[type, ...] = ()
291291
auto_default: bool = False
@@ -667,7 +667,7 @@ def dataclass_to_table(self, cls: type[DataclassInstance]) -> Table:
667667
raise TypeError(f"error processing data-class: {cls}") from e
668668

669669
# foreign/primary key constraints
670-
constraints = []
670+
constraints: list[Constraint] = []
671671
if self.options.foreign_constraints:
672672
constraints.extend(self.dataclass_to_constraints(cls))
673673

pysqlsync/resultset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def resultset_unwrap_object(signature: type[D], records: Iterable[Any]) -> list[
4141
if not is_dataclass_type(signature):
4242
raise TypeError(f"expected: data-class type as result-set signature; got: {signature}")
4343

44-
names = [name for name in signature.__dataclass_fields__.keys()]
44+
names = [name for name in signature.__dataclass_fields__.keys()] # pyright: ignore[reportUnknownMemberType]
4545
return [signature(**{name: record.__getattribute__(name) for name in names}) for record in records]
4646

4747

requirements-dev.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# core
2-
json_strong_typing >= 0.4.1
2+
json_strong_typing >= 0.4.2
33
typing_extensions >= 4.15; python_version<"3.12"
44

55
# certificate stores
6-
certifi >= 2025.10.5; python_version<"3.10"
6+
certifi >= 2025.11.12; python_version<"3.10"
77
truststore >= 0.10; python_version>="3.10"
88

99
# data export/import

0 commit comments

Comments
 (0)