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

Drop compatibility with Python 3.5 #9101

Open
wants to merge 16 commits into
base: development
Choose a base branch
from

Conversation

gilles-peskine-arm
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm commented May 6, 2024

Move to Python 3.6 as the minimum Python version that actually works. This is the oldest Python version that we promise to support in Mbed TLS 2.28 LTS.

Take advantage of this to upgrade pylint (and also mypy and cryptography) to the last version that still supports Python 3.6.

Resolves #9092. Not sufficient for #9091, unfortunately: this version of Pylint still crashes on some files with Python ≥3.11.

Prerequisites:

PR checklist

  • changelog no (we're still within the same documented platform requirements)
  • 3.6 backport TODO
  • 2.28 backport TODO
  • tests CI, but also need some manual checks for scripts that aren't supported on the CI: TODO

Use less ancient versions to benefit from bug fixes and improvements.

Use the last versions that support Python 3.5.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Fix mypy tests/scripts/audit-validity-dates.py

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Pacify Pylint 2.6.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Not a big deal in those particular cases, but follow Pylint 2.6's suggestion.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Annotate some false positives that appeared when moving from Pylint 2.4.4
to Pylint 2.6.2.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Use less ancient versions to benefit from bug fixes and improvements.

Use the last versions that support Python 3.6.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This now needs to be conveyed through no-docstring-rgx.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Always specify UTF-8 when dealing with text files, or occasionally ASCII
when writing out pure ASCII.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Using context managers ensures that resources are cleaned up on an
exception. When writing files, they ensure that all data is flushed
out (I think CPython takes care of it anyway, but not Pypy). When reading
files, this only prevents leaking the file descriptor (under Python
implementations that don't close files automatically, such as Pypy), which
doesn't really matter to us since our scripts are short-lived and exit
immediately on error, but it's good practice anyway.

Leave one process call alone in test_psa_compliance because it would take
more refactoring than it's worth. It's in main() so not worth much.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Since we're dropping Python 3.5 compatibility, we can start using f-strings.
But that's only a minor stylistic improvement, not worth spending time now
to upgrade our existing code. So don't nag about it for the time being.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Sometimes Pylint is too eager to "consider using".

Pass Pylint 2.6.2 with Python 3.6.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Since we happily assume UTF-8 encoding for all our source files, there's no
point in being extra-robust by occasionally opening them in binary mode. So
we can simplify read_file_lines. This fixes complaints from mypy, which
wasn't smart enough for the `open() if ... else open()` version.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Starting with this commit, `pip install -r scripts/ci.requirements.txt` no
longer works under Python 3.5.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
@gilles-peskine-arm gilles-peskine-arm added component-platform Portability layer and build scripts needs-ci Needs to pass CI tests needs-preceding-pr Requires another PR to be merged first size-s Estimated task size: small (~2d) component-test Test framework and CI scripts priority-medium Medium priority - this can be reviewed as time permits labels May 6, 2024
@gilles-peskine-arm gilles-peskine-arm added needs-work and removed needs-preceding-pr Requires another PR to be merged first labels May 12, 2024
Useful for debugging CI pipelines.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
@gilles-peskine-arm gilles-peskine-arm force-pushed the python-checks-last-3.6-development branch from 50f5898 to 545db1b Compare May 13, 2024 09:56
Avoid a Rust dependency, needed on platforms where no pre-built wheels are
available.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
@gilles-peskine-arm gilles-peskine-arm added needs-preceding-pr Requires another PR to be merged first and removed needs-work needs-ci Needs to pass CI tests labels May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component-platform Portability layer and build scripts component-test Test framework and CI scripts needs-preceding-pr Requires another PR to be merged first priority-medium Medium priority - this can be reviewed as time permits size-s Estimated task size: small (~2d)
Projects
Status: In Development
Development

Successfully merging this pull request may close these issues.

pylint complains about unsubscriptable-object under Python ≥3.9
1 participant