From 8ad39438fafef653d019e3214037c96257507e55 Mon Sep 17 00:00:00 2001 From: Shay Date: Mon, 20 Dec 2021 04:18:09 -0800 Subject: Add opentracing types (#11603) --- setup.py | 1 + 1 file changed, 1 insertion(+) (limited to 'setup.py') diff --git a/setup.py b/setup.py index 2c6fb9aacb..812459074a 100755 --- a/setup.py +++ b/setup.py @@ -107,6 +107,7 @@ CONDITIONAL_REQUIREMENTS["mypy"] = [ "mypy-zope==0.3.2", "types-bleach>=4.1.0", "types-jsonschema>=3.2.0", + "types-opentracing>=2.4.2", "types-Pillow>=8.3.4", "types-pyOpenSSL>=20.0.7", "types-PyYAML>=5.4.10", -- cgit 1.5.1 From 7a7ca8f2263f8750b8ff2c18b9aefaf4a3626235 Mon Sep 17 00:00:00 2001 From: V02460 Date: Mon, 20 Dec 2021 16:34:46 +0100 Subject: Use mock from standard library (#11588) Instead of the backported version. --- changelog.d/11588.removal | 1 + setup.py | 4 +--- tests/storage/test_background_update.py | 17 ++++++++--------- 3 files changed, 10 insertions(+), 12 deletions(-) create mode 100644 changelog.d/11588.removal (limited to 'setup.py') diff --git a/changelog.d/11588.removal b/changelog.d/11588.removal new file mode 100644 index 0000000000..f781021e11 --- /dev/null +++ b/changelog.d/11588.removal @@ -0,0 +1 @@ +Replace `mock` package by its standard library version. diff --git a/setup.py b/setup.py index 812459074a..e113da6782 100755 --- a/setup.py +++ b/setup.py @@ -120,9 +120,7 @@ CONDITIONAL_REQUIREMENTS["mypy"] = [ # Tests assume that all optional dependencies are installed. # # parameterized_class decorator was introduced in parameterized 0.7.0 -# -# We use `mock` library as that backports `AsyncMock` to Python 3.6 -CONDITIONAL_REQUIREMENTS["test"] = ["parameterized>=0.7.0", "mock>=4.0.0"] +CONDITIONAL_REQUIREMENTS["test"] = ["parameterized>=0.7.0"] CONDITIONAL_REQUIREMENTS["dev"] = ( CONDITIONAL_REQUIREMENTS["lint"] diff --git a/tests/storage/test_background_update.py b/tests/storage/test_background_update.py index d77c001506..6156dfac4e 100644 --- a/tests/storage/test_background_update.py +++ b/tests/storage/test_background_update.py @@ -12,15 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Use backported mock for AsyncMock support on Python 3.6. -from mock import Mock +from unittest.mock import Mock from twisted.internet.defer import Deferred, ensureDeferred from synapse.storage.background_updates import BackgroundUpdater from tests import unittest -from tests.test_utils import make_awaitable +from tests.test_utils import make_awaitable, simple_async_mock class BackgroundUpdateTestCase(unittest.HomeserverTestCase): @@ -116,14 +115,14 @@ class BackgroundUpdateControllerTestCase(unittest.HomeserverTestCase): ) # Mock out the AsyncContextManager - self._update_ctx_manager = Mock(spec=["__aenter__", "__aexit__"]) - self._update_ctx_manager.__aenter__ = Mock( - return_value=make_awaitable(None), - ) - self._update_ctx_manager.__aexit__ = Mock(return_value=make_awaitable(None)) + class MockCM: + __aenter__ = simple_async_mock(return_value=None) + __aexit__ = simple_async_mock(return_value=None) + + self._update_ctx_manager = MockCM # Mock out the `update_handler` callback - self._on_update = Mock(return_value=self._update_ctx_manager) + self._on_update = Mock(return_value=self._update_ctx_manager()) # Define a default batch size value that's not the same as the internal default # value (100). -- cgit 1.5.1 From fcfe67578f70bb4f150b83cfad708f5bc0474c1e Mon Sep 17 00:00:00 2001 From: Shay Date: Thu, 23 Dec 2021 20:22:15 -0800 Subject: Update to the current version of Black and run it on Synapse codebase (#11596) * update black version * run updated version of black on code * newsfragment * enumerate python versions --- changelog.d/11596.misc | 1 + pyproject.toml | 2 +- setup.py | 2 +- synapse/logging/context.py | 1 - synapse/util/caches/lrucache.py | 1 - 5 files changed, 3 insertions(+), 4 deletions(-) create mode 100644 changelog.d/11596.misc (limited to 'setup.py') diff --git a/changelog.d/11596.misc b/changelog.d/11596.misc new file mode 100644 index 0000000000..3064bc632d --- /dev/null +++ b/changelog.d/11596.misc @@ -0,0 +1 @@ +Update black version and run it on all the files. \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 8bca1fa4ef..963f149c6a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ showcontent = true [tool.black] -target-version = ['py36'] +target-version = ['py37', 'py38', 'py39', 'py310'] exclude = ''' ( diff --git a/setup.py b/setup.py index e113da6782..fbb0133016 100755 --- a/setup.py +++ b/setup.py @@ -96,7 +96,7 @@ CONDITIONAL_REQUIREMENTS["all"] = list(ALL_OPTIONAL_REQUIREMENTS) # We pin black so that our tests don't start failing on new releases. CONDITIONAL_REQUIREMENTS["lint"] = [ "isort==5.7.0", - "black==21.6b0", + "black==21.12b0", "flake8-comprehensions", "flake8-bugbear==21.3.2", "flake8", diff --git a/synapse/logging/context.py b/synapse/logging/context.py index 25e78cc82f..d4ee893376 100644 --- a/synapse/logging/context.py +++ b/synapse/logging/context.py @@ -68,7 +68,6 @@ try: def get_thread_resource_usage() -> "Optional[resource.struct_rusage]": return resource.getrusage(RUSAGE_THREAD) - except Exception: # If the system doesn't support resource.getrusage(RUSAGE_THREAD) then we # won't track resource usage. diff --git a/synapse/util/caches/lrucache.py b/synapse/util/caches/lrucache.py index eb96f7e665..3f11a2f9dd 100644 --- a/synapse/util/caches/lrucache.py +++ b/synapse/util/caches/lrucache.py @@ -69,7 +69,6 @@ try: sizer.exclude_refs((), None, "") return sizer.asizeof(val, limit=100 if recurse else 0) - except ImportError: def _get_size_of(val: Any, *, recurse: bool = True) -> int: -- cgit 1.5.1 From 13c974ed358c28940588f447b363063c76063fc2 Mon Sep 17 00:00:00 2001 From: Shay Date: Mon, 3 Jan 2022 11:17:16 -0800 Subject: Drop Bionic from Debian builds (#11633) * update Trove classifiers to remove py36 * stop building bionic * update dh-virtualenv * newsfragment * fix newsfragment * update version refs * another try at correct tag * Update changelog --- changelog.d/11633.misc | 1 + docker/Dockerfile-dhvirtualenv | 9 ++++----- scripts-dev/build_debian_packages | 1 - setup.py | 1 - 4 files changed, 5 insertions(+), 7 deletions(-) create mode 100644 changelog.d/11633.misc (limited to 'setup.py') diff --git a/changelog.d/11633.misc b/changelog.d/11633.misc new file mode 100644 index 0000000000..73e814e58e --- /dev/null +++ b/changelog.d/11633.misc @@ -0,0 +1 @@ +Drop support for Python 3.6 and Ubuntu 18.04. \ No newline at end of file diff --git a/docker/Dockerfile-dhvirtualenv b/docker/Dockerfile-dhvirtualenv index 1dd88140c7..fbc1d2346f 100644 --- a/docker/Dockerfile-dhvirtualenv +++ b/docker/Dockerfile-dhvirtualenv @@ -16,7 +16,7 @@ ARG distro="" ### Stage 0: build a dh-virtualenv ### -# This is only really needed on bionic and focal, since other distributions we +# This is only really needed on focal, since other distributions we # care about have a recent version of dh-virtualenv by default. Unfortunately, # it looks like focal is going to be with us for a while. # @@ -36,9 +36,8 @@ RUN env DEBIAN_FRONTEND=noninteractive apt-get install \ wget # fetch and unpack the package -# TODO: Upgrade to 1.2.2 once bionic is dropped (1.2.2 requires debhelper 12; bionic has only 11) RUN mkdir /dh-virtualenv -RUN wget -q -O /dh-virtualenv.tar.gz https://github.com/spotify/dh-virtualenv/archive/ac6e1b1.tar.gz +RUN wget -q -O /dh-virtualenv.tar.gz https://github.com/spotify/dh-virtualenv/archive/refs/tags/1.2.2.tar.gz RUN tar -xv --strip-components=1 -C /dh-virtualenv -f /dh-virtualenv.tar.gz # install its build deps. We do another apt-cache-update here, because we might @@ -86,12 +85,12 @@ RUN apt-get update -qq -o Acquire::Languages=none \ libpq-dev \ xmlsec1 -COPY --from=builder /dh-virtualenv_1.2~dev-1_all.deb / +COPY --from=builder /dh-virtualenv_1.2.2-1_all.deb / # install dhvirtualenv. Update the apt cache again first, in case we got a # cached cache from docker the first time. RUN apt-get update -qq -o Acquire::Languages=none \ - && apt-get install -yq /dh-virtualenv_1.2~dev-1_all.deb + && apt-get install -yq /dh-virtualenv_1.2.2-1_all.deb WORKDIR /synapse/source ENTRYPOINT ["bash","/synapse/source/docker/build_debian.sh"] diff --git a/scripts-dev/build_debian_packages b/scripts-dev/build_debian_packages index 3a9a2d257c..4d34e90703 100755 --- a/scripts-dev/build_debian_packages +++ b/scripts-dev/build_debian_packages @@ -24,7 +24,6 @@ DISTS = ( "debian:bullseye", "debian:bookworm", "debian:sid", - "ubuntu:bionic", # 18.04 LTS (our EOL forced by Py36 on 2021-12-23) "ubuntu:focal", # 20.04 LTS (our EOL forced by Py38 on 2024-10-14) "ubuntu:hirsute", # 21.04 (EOL 2022-01-05) "ubuntu:impish", # 21.10 (EOL 2022-07) diff --git a/setup.py b/setup.py index fbb0133016..e618ff898b 100755 --- a/setup.py +++ b/setup.py @@ -162,7 +162,6 @@ setup( "Topic :: Communications :: Chat", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", -- cgit 1.5.1