Skip to content

Commit c1d3383

Browse files
authored
PYTHON-3907 add --disallow-untyped-defs for mypy (#1351)
1 parent f7738b8 commit c1d3383

25 files changed

+43
-36
lines changed

bson/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,7 @@ def has_c() -> bool:
14061406
return _USE_C
14071407

14081408

1409-
def _after_fork():
1409+
def _after_fork() -> None:
14101410
"""Releases the ObjectID lock child."""
14111411
if ObjectId._inc_lock.locked():
14121412
ObjectId._inc_lock.release()

bson/binary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,5 +365,5 @@ def __hash__(self) -> int:
365365
def __ne__(self, other: Any) -> bool:
366366
return not self == other
367367

368-
def __repr__(self):
368+
def __repr__(self) -> str:
369369
return f"Binary({bytes.__repr__(self)}, {self.__subtype})"

bson/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def scope(self) -> Optional[Mapping[str, Any]]:
8686
"""Scope dictionary for this instance or ``None``."""
8787
return self.__scope
8888

89-
def __repr__(self):
89+
def __repr__(self) -> str:
9090
return f"Code({str.__repr__(self)}, {self.__scope!r})"
9191

9292
def __eq__(self, other: Any) -> bool:

bson/codec_options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def _validate_type_encoder(self, codec: _Codec) -> None:
172172
)
173173
raise TypeError(err_msg)
174174

175-
def __repr__(self):
175+
def __repr__(self) -> str:
176176
return "{}(type_codecs={!r}, fallback_encoder={!r})".format(
177177
self.__class__.__name__,
178178
self.__type_codecs,
@@ -465,7 +465,7 @@ def _options_dict(self) -> Dict[str, Any]:
465465
"datetime_conversion": self.datetime_conversion,
466466
}
467467

468-
def __repr__(self):
468+
def __repr__(self) -> str:
469469
return f"{self.__class__.__name__}({self._arguments_repr()})"
470470

471471
def with_options(self, **kwargs: Any) -> "CodecOptions":

bson/datetime_ms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ def __int__(self) -> int:
111111
# Timezones are hashed by their offset, which is a timedelta
112112
# and therefore there are more than 24 possible timezones.
113113
@functools.lru_cache(maxsize=None)
114-
def _min_datetime_ms(tz=datetime.timezone.utc):
114+
def _min_datetime_ms(tz: datetime.timezone = datetime.timezone.utc) -> int:
115115
return _datetime_to_millis(datetime.datetime.min.replace(tzinfo=tz))
116116

117117

118118
@functools.lru_cache(maxsize=None)
119-
def _max_datetime_ms(tz=datetime.timezone.utc):
119+
def _max_datetime_ms(tz: datetime.timezone = datetime.timezone.utc) -> int:
120120
return _datetime_to_millis(datetime.datetime.max.replace(tzinfo=tz))
121121

122122

bson/dbref.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def as_doc(self) -> SON[str, Any]:
101101
doc.update(self.__kwargs)
102102
return doc
103103

104-
def __repr__(self):
104+
def __repr__(self) -> str:
105105
extra = "".join([f", {k}={v!r}" for k, v in self.__kwargs.items()])
106106
if self.database is None:
107107
return f"DBRef({self.collection!r}, {self.id!r}{extra})"

bson/decimal128.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def __str__(self) -> str:
296296
return "NaN"
297297
return str(dec)
298298

299-
def __repr__(self):
299+
def __repr__(self) -> str:
300300
return f"Decimal128('{str(self)}')"
301301

302302
def __setstate__(self, value: Tuple[int, int]) -> None:

bson/json_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class JSONOptions(CodecOptions):
224224
datetime_representation: int
225225
strict_uuid: bool
226226

227-
def __init__(self, *args, **kwargs):
227+
def __init__(self, *args: Any, **kwargs: Any):
228228
"""Encapsulates JSON options for :func:`dumps` and :func:`loads`.
229229
230230
:Parameters:

bson/max_key.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ def __ge__(self, dummy: Any) -> bool:
5050
def __gt__(self, other: Any) -> bool:
5151
return not isinstance(other, MaxKey)
5252

53-
def __repr__(self):
53+
def __repr__(self) -> str:
5454
return "MaxKey()"

bson/min_key.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ def __ge__(self, other: Any) -> bool:
5050
def __gt__(self, dummy: Any) -> bool:
5151
return False
5252

53-
def __repr__(self):
53+
def __repr__(self) -> str:
5454
return "MinKey()"

0 commit comments

Comments
 (0)