Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous type-checking updates #2614

Merged
merged 3 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading