Merge pull request #1347 from tahoe-lafs/4075-dependency-updates

Dependency updates and some improvements to typechecking
This commit is contained in:
meejah 2023-11-22 17:23:22 -07:00 committed by GitHub
commit 638d8d66c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 15 deletions

0
newsfragments/4075.minor Normal file
View File

View File

@ -11,6 +11,7 @@ from typing import (
Optional,
Union,
List,
IO
)
from twisted.python.filepath import FilePath
@ -178,6 +179,7 @@ def load_grid_manager(config_path: Optional[FilePath]):
:raises: ValueError if the confguration is invalid or IOError if
expected files can't be opened.
"""
config_file: Union[IO[bytes], IO[str]]
if config_path is None:
config_file = sys.stdin
else:

View File

@ -200,14 +200,14 @@ def read_config(basedir, portnumfile, generated_files: Iterable = (), _valid_con
config_path = FilePath(basedir).child("tahoe.cfg")
try:
config_str = config_path.getContent()
config_bytes = config_path.getContent()
except EnvironmentError as e:
if e.errno != errno.ENOENT:
raise
# The file is missing, just create empty ConfigParser.
config_str = u""
else:
config_str = config_str.decode("utf-8-sig")
config_str = config_bytes.decode("utf-8-sig")
return config_from_string(
basedir,

View File

@ -15,7 +15,7 @@ scheduler affinity or cgroups, but that's not the end of the world.
"""
import os
from typing import TypeVar, Callable
from typing import TypeVar, Callable, cast
from functools import partial
import threading
from typing_extensions import ParamSpec
@ -24,8 +24,9 @@ from unittest import TestCase
from twisted.python.threadpool import ThreadPool
from twisted.internet.threads import deferToThreadPool
from twisted.internet import reactor
from twisted.internet.interfaces import IReactorFromThreads
_CPU_THREAD_POOL = ThreadPool(minthreads=0, maxthreads=os.cpu_count(), name="TahoeCPU")
_CPU_THREAD_POOL = ThreadPool(minthreads=0, maxthreads=os.cpu_count() or 1, name="TahoeCPU")
if hasattr(threading, "_register_atexit"):
# This is a private API present in Python 3.8 or later, specifically
# designed for thread pool shutdown. Since it's private, it might go away
@ -64,7 +65,7 @@ async def defer_to_thread(f: Callable[P, R], *args: P.args, **kwargs: P.kwargs)
return f(*args, **kwargs)
# deferToThreadPool has no type annotations...
result = await deferToThreadPool(reactor, _CPU_THREAD_POOL, f, *args, **kwargs)
result = await deferToThreadPool(cast(IReactorFromThreads, reactor), _CPU_THREAD_POOL, f, *args, **kwargs)
return result

View File

@ -874,6 +874,6 @@ def add_static_children(root: IResource):
for child in static_dir.iterdir():
child_path = child.name.encode("utf-8")
root.putChild(child_path, static.File(
temporary_file_manager.enter_context(as_file(child))
str(temporary_file_manager.enter_context(as_file(child)))
))
weakref.finalize(root, temporary_file_manager.close)

19
tox.ini
View File

@ -101,11 +101,7 @@ skip_install = true
deps =
# Pin a specific version so we get consistent outcomes; update this
# occasionally:
ruff == 0.0.287
# towncrier doesn't work with importlib_resources 6.0.0
# https://github.com/twisted/towncrier/issues/528
# Will be fixed in first version of Towncrier that is larger than 2023.6.
importlib_resources < 6.0.0
ruff == 0.1.6
towncrier
# On macOS, git inside of towncrier needs $HOME.
passenv = HOME
@ -137,8 +133,13 @@ deps =
types-pyOpenSSL
foolscap
# Upgrade when new releases come out:
Twisted==23.8.0
commands = mypy src
Twisted==23.10.0
commands =
# Different versions of Python have a different standard library, and we
# want to be compatible with all the variations. For speed's sake we only do
# the earliest and latest versions.
mypy --python-version=3.8 src
mypy --python-version=3.12 src
[testenv:draftnews]
@ -146,7 +147,7 @@ passenv = TAHOE_LAFS_*,PIP_*,SUBUNITREPORTER_*,USERPROFILE,HOMEDRIVE,HOMEPATH,CO
deps =
# see comment in [testenv] about "certifi"
certifi
towncrier==21.3.0
towncrier==23.11.0
commands =
python -m towncrier --draft --config towncrier.toml
@ -158,7 +159,7 @@ whitelist_externals =
deps =
# see comment in [testenv] about "certifi"
certifi
towncrier==21.3.0
towncrier==23.11.0
commands =
python -m towncrier --yes --config towncrier.toml
# commit the changes