Skip to content

Commit

Permalink
Merge pull request #2614 from sopel-irc/type-check-updates
Browse files Browse the repository at this point in the history
Miscellaneous type-checking updates
  • Loading branch information
dgw authored Aug 31, 2024
2 parents 1237568 + c8802f7 commit 1c6aeb9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ sphinx-rfcsection~=0.1.1
vcrpy @ git+https://github.com/sopel-irc/vcrpy@uncap-urllib3
# type check
mypy>=1.3,<2
# for `pkg_resources`; first version in which it's typed
# we don't use `pkg_resources` directly, but mypy still cares
setuptools>=71.1
sqlalchemy[mypy]>=1.4,<1.5
types-pkg-resources~=0.1.3
types-pytz
types-requests>=2,<3
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ dependencies = [
"importlib_metadata>=3.6",
"packaging>=23.2",
"sopel-help>=0.4.0",
"typing_extensions>=4.4", # for @typing.override, added in py3.12
]

[project.urls]
Expand Down
6 changes: 3 additions & 3 deletions sopel/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def write(self, string):
:param str string: the string to write
"""
if not self.quiet:
if not self.quiet and sys.__stderr__ and sys.__stdout__:
try:
if self.stderr:
sys.__stderr__.write(string)
Expand All @@ -179,9 +179,9 @@ def write(self, string):

def flush(self):
"""Flush the file writing buffer."""
if self.stderr:
if self.stderr and sys.__stderr__:
sys.__stderr__.flush()
else:
elif sys.__stdout__:
sys.__stdout__.flush()


Expand Down
3 changes: 3 additions & 0 deletions sopel/tools/memories.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import threading
from typing import Any, Optional, TYPE_CHECKING, Union

from typing_extensions import override

from .identifiers import Identifier, IdentifierFactory

if TYPE_CHECKING:
Expand Down Expand Up @@ -259,6 +261,7 @@ def pop(self, key: str, default=_NO_DEFAULT):
return super().pop(self._make_key(key))
return super().pop(self._make_key(key), default)

@override
def update(self, maybe_mapping=tuple()):
"""Update this ``SopelIdentifierMemory`` with key-value pairs.
Expand Down

0 comments on commit 1c6aeb9

Please sign in to comment.