From d6d38cd977a4f7dcc263f1220e774368ed0ed864 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Mon, 15 May 2023 15:51:35 -0500 Subject: [PATCH 1/5] Run mypy type checking with the minimum supported Python version Follow-up/related to https://github.com/matrix-org/synapse/pull/15599 --- .github/workflows/tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 51cbeb32980c..ecca74f6f649 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -95,6 +95,10 @@ jobs: - name: Setup Poetry uses: matrix-org/setup-python-poetry@v1 with: + # We set this as our minimum supported Python version. We use the oldest + # Python version because later Python versions can include some overloads + # which don't work in the older versions. + python-version: '3.7' # We want to make use of type hints in optional dependencies too. extras: all # We have seen odd mypy failures that were resolved when we started From 0e962e357267d9f7f257bc84144f8336a375c660 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Mon, 15 May 2023 15:54:41 -0500 Subject: [PATCH 2/5] Add changelog --- changelog.d/15602.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/15602.misc diff --git a/changelog.d/15602.misc b/changelog.d/15602.misc new file mode 100644 index 000000000000..cdd0c039bd4a --- /dev/null +++ b/changelog.d/15602.misc @@ -0,0 +1 @@ +Run mypy type checking with the minimum supported Python version to catch new usage that isn't backwards-compatible. From 7aa8af7f3a3ab61e7f996dbcb37891a7496ce589 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Mon, 15 May 2023 18:08:01 -0500 Subject: [PATCH 3/5] Use Python 3.8 instead of 3.7 which EOL in a matter of weeks In any case, minium Python 3.8 support is better than winging it on Python 3.11 Relevant conversation: https://matrix.to/#/!vcyiEtMVHIhWXcJAfl:sw1v.org/$4BFQ7czgyRBVdC9yHpcgfUXcLoTNpUWLiY-NRM9P-h0?via=matrix.org&via=element.io&via=pixie.town --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ecca74f6f649..41d63d983edc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -98,7 +98,7 @@ jobs: # We set this as our minimum supported Python version. We use the oldest # Python version because later Python versions can include some overloads # which don't work in the older versions. - python-version: '3.7' + python-version: '3.8' # We want to make use of type hints in optional dependencies too. extras: all # We have seen odd mypy failures that were resolved when we started From 7007f381cb452190160fdb6d8f3971ebb1ad344b Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Mon, 15 May 2023 18:24:40 -0500 Subject: [PATCH 4/5] Use mypy.ini which works to see the lints locally even if you're using a newer Python version See https://github.com/matrix-org/synapse/pull/15602#discussion_r1194443243 --- .github/workflows/tests.yml | 4 ---- mypy.ini | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 41d63d983edc..51cbeb32980c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -95,10 +95,6 @@ jobs: - name: Setup Poetry uses: matrix-org/setup-python-poetry@v1 with: - # We set this as our minimum supported Python version. We use the oldest - # Python version because later Python versions can include some overloads - # which don't work in the older versions. - python-version: '3.8' # We want to make use of type hints in optional dependencies too. extras: all # We have seen odd mypy failures that were resolved when we started diff --git a/mypy.ini b/mypy.ini index 5e7057cfb7b1..43f792517259 100644 --- a/mypy.ini +++ b/mypy.ini @@ -13,6 +13,10 @@ no_implicit_optional = True disallow_untyped_defs = True strict_equality = True warn_redundant_casts = True +# We set this as our minimum supported Python version. We use the oldest Python version +# because later Python versions can include some types, overloads, etc which don't work +# in the older versions. +python_version = 3.8 files = docker/, From 9ba543a368776337b9eea427b5bcc156f2adeec2 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Mon, 15 May 2023 18:30:07 -0500 Subject: [PATCH 5/5] More concise comment --- mypy.ini | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mypy.ini b/mypy.ini index 43f792517259..3363c6daeee7 100644 --- a/mypy.ini +++ b/mypy.ini @@ -13,9 +13,8 @@ no_implicit_optional = True disallow_untyped_defs = True strict_equality = True warn_redundant_casts = True -# We set this as our minimum supported Python version. We use the oldest Python version -# because later Python versions can include some types, overloads, etc which don't work -# in the older versions. +# Run mypy type checking with the minimum supported Python version to catch new usage +# that isn't backwards-compatible (types, overloads, etc). python_version = 3.8 files =