From 29a64a4889f94bafbd0062d7fc5052858523b25c Mon Sep 17 00:00:00 2001 From: Isaac Good Date: Fri, 14 Jul 2023 05:53:39 -0700 Subject: [PATCH] Remove Python 2 references from the track (#3437) * Remove Python 2 references from the track * Revert unintentional whitespace changes to test files [no important files changed] --- concepts/comparisons/about.md | 2 +- concepts/string-formatting/about.md | 2 +- docs/ABOUT.md | 2 +- docs/INSTALLATION.md | 4 ++-- exercises/concept/black-jack/.docs/introduction.md | 2 +- exercises/practice/circular-buffer/.meta/example.py | 2 +- exercises/practice/pythagorean-triplet/.meta/template.j2 | 3 --- .../practice/pythagorean-triplet/pythagorean_triplet_test.py | 4 ---- exercises/practice/sublist/sublist.py | 3 +-- pylintrc | 5 ----- reference/exercise-concepts/rna-transcription.md | 2 +- 11 files changed, 9 insertions(+), 22 deletions(-) diff --git a/concepts/comparisons/about.md b/concepts/comparisons/about.md index 568b6603c1..c2f5faaad9 100644 --- a/concepts/comparisons/about.md +++ b/concepts/comparisons/about.md @@ -82,7 +82,7 @@ False Strings (`str`) are compared [_lexicographically_][lexographic order], using their individual Unicode code points (_the result of passing each code point in the `str` to the built-in function [`ord()`][ord], which returns an `int`_). If all code points in both strings match and are _**in the same order**_, the two strings are considered equal. This comparison is done in a 'pair-wise' fashion - first-to-first, second-to-second, etc. -Unlike in Python 2.x, in Python 3.x, `str` and `bytes` cannot be directly coerced/compared. +In Python 3.x, `str` and `bytes` cannot be directly coerced/compared. ```python >>> 'Python' > 'Rust' diff --git a/concepts/string-formatting/about.md b/concepts/string-formatting/about.md index 46452b4163..f3b2756b76 100644 --- a/concepts/string-formatting/about.md +++ b/concepts/string-formatting/about.md @@ -149,7 +149,7 @@ Use of the `%` operator for formatting is the oldest method of string formatting It comes from the C language and allows the use of positional arguments to build a `str`. This method has been superseded by both `f-strings` and `str.format()`, which is why the nickname for `%` formatting is _'Old Style'_. -It can be still found in python 2 and/or legacy code. +It can be still found in Python 2 and/or legacy code. While using this method will work in Python 3.x, `%` formatting is usually avoided because it can be error-prone, is less efficient, has fewer options available, and any placeholder-argument mismatch can raise an exception. Using the `%` operator is similar to [`printf()`][printf-style-docs], so it is also sometimes called _printf formatting_. diff --git a/docs/ABOUT.md b/docs/ABOUT.md index 05c56799ac..f0d52389bf 100644 --- a/docs/ABOUT.md +++ b/docs/ABOUT.md @@ -22,7 +22,7 @@ The [zen of Python (PEP 20)][the zen of python] and [What is Pythonic?][what is Tests and tooling for this track currently support `3.7` - `3.10.6` (_tests_) and [`Python 3.11`][311-new-features] (_tooling_). It is highly recommended that students upgrade to at least `Python 3.8`, as some features used by this track may not be supported in earlier versions. -That being said, most of the exercises will work with `Python 3.6+`, and many are compatible with `Python 2.7+`. +That being said, most of the exercises will work with `Python 3.6+`. But we don't guarantee support for versions not listed under [Active Python Releases][active-python-releases]. We will try to note when a feature is only available in a certain version. diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index 8bf42a0452..c8eb68ca46 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -6,7 +6,7 @@ Real Python also offers a [nice guide][helpful guide] to installation on various Finally, these posts by Brett Cannon [A quick-and-dirty guide][quick-and-dirty] and [Why you should use `python -m pip`][python-m-pip], give very helpful advice on how to manage Python installations and packages. **Note for MacOS users:** prior to MacOS Monterey (12.3), `Python 2.7` came pre-installed with the operating system. -Using `Python 2.7` with Exercism or most other programs is not recommended. +Using `Python 2.7` with Exercism or most other programs is not supported. You should instead install [Python 3][Python-three downloads] via one of the methods detailed below. As of MacOS Monterey (12.3), no version of Python will be pre-installed via MacOS. @@ -20,7 +20,7 @@ Some quick links into the documentation by operating system: Exercism tests and tooling currently support `3.7` - `3.10.6` (_tests_) and [`Python 3.11`][311-new-features] (_tooling_). Exceptions to this support are noted where they occur. -Most of the exercises will work with `Python 3.6+`, and many are compatible with `Python 2.7+`. +Most of the exercises will work with `Python 3.6+`. But we don't guarantee support for versions not listed under [Active Python Releases][active-python-releases]. diff --git a/exercises/concept/black-jack/.docs/introduction.md b/exercises/concept/black-jack/.docs/introduction.md index b79091f4ff..207229359d 100644 --- a/exercises/concept/black-jack/.docs/introduction.md +++ b/exercises/concept/black-jack/.docs/introduction.md @@ -80,7 +80,7 @@ False Unlike numbers, strings (`str`) are compared [_lexicographically_][lexographic order], using their individual Unicode code points (_the result of passing each code point in the `str` to the built-in function [`ord()`][ord], which returns an `int`_). If all code points in both strings match and are _**in the same order**_, the two strings are considered equal. This comparison is done in a 'pair-wise' fashion - first-to-first, second-to-second, etc. -Unlike in Python 2.x, in Python 3.x, `str` and `bytes` cannot be directly coerced/compared. +In Python 3.x, `str` and `bytes` cannot be directly coerced/compared. ```python >>> 'Python' > 'Rust' diff --git a/exercises/practice/circular-buffer/.meta/example.py b/exercises/practice/circular-buffer/.meta/example.py index 8438b9839f..538cc7bc5e 100644 --- a/exercises/practice/circular-buffer/.meta/example.py +++ b/exercises/practice/circular-buffer/.meta/example.py @@ -25,7 +25,7 @@ def __init__(self, capacity): self.read_point = 0 self.write_point = 0 - # (protected) helper method to support python 2/3 + # (protected) helper method def _update_buffer(self, data): try: self.buffer[self.write_point] = data diff --git a/exercises/practice/pythagorean-triplet/.meta/template.j2 b/exercises/practice/pythagorean-triplet/.meta/template.j2 index b3836a5442..e52cda4e23 100644 --- a/exercises/practice/pythagorean-triplet/.meta/template.j2 +++ b/exercises/practice/pythagorean-triplet/.meta/template.j2 @@ -2,9 +2,6 @@ {{ macros.header() }} -# Python 2/3 compatibility -if not hasattr(unittest.TestCase, 'assertCountEqual'): - unittest.TestCase.assertCountEqual = unittest.TestCase.assertItemsEqual class {{ exercise | camel_case }}Test(unittest.TestCase): {% for case in cases -%} diff --git a/exercises/practice/pythagorean-triplet/pythagorean_triplet_test.py b/exercises/practice/pythagorean-triplet/pythagorean_triplet_test.py index 70d501c4fb..bb094c909d 100644 --- a/exercises/practice/pythagorean-triplet/pythagorean_triplet_test.py +++ b/exercises/practice/pythagorean-triplet/pythagorean_triplet_test.py @@ -6,10 +6,6 @@ # Tests adapted from `problem-specifications//canonical-data.json` -# Python 2/3 compatibility -if not hasattr(unittest.TestCase, "assertCountEqual"): - unittest.TestCase.assertCountEqual = unittest.TestCase.assertItemsEqual - class PythagoreanTripletTest(unittest.TestCase): def test_triplets_whose_sum_is_12(self): diff --git a/exercises/practice/sublist/sublist.py b/exercises/practice/sublist/sublist.py index 428d3aa656..35410301d5 100644 --- a/exercises/practice/sublist/sublist.py +++ b/exercises/practice/sublist/sublist.py @@ -1,8 +1,7 @@ """ This exercise stub and the test suite contain several enumerated constants. -Since Python 2 does not have the enum module, the idiomatic way to write -enumerated constants has traditionally been a NAME assigned to an arbitrary, +Enumerated constants can be done with a NAME assigned to an arbitrary, but unique value. An integer is traditionally used because it’s memory efficient. It is a common practice to export both constants and functions that work with diff --git a/pylintrc b/pylintrc index 745e6f039a..09795978bc 100644 --- a/pylintrc +++ b/pylintrc @@ -341,11 +341,6 @@ known-standard-library= # Force import order to recognize a module as part of a third party library. known-third-party=enchant, absl -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - [CLASSES] diff --git a/reference/exercise-concepts/rna-transcription.md b/reference/exercise-concepts/rna-transcription.md index b2b1294681..004ded9511 100644 --- a/reference/exercise-concepts/rna-transcription.md +++ b/reference/exercise-concepts/rna-transcription.md @@ -2,7 +2,7 @@ ## Example implementation -Modified from the existing [example.py](https://github.com/exercism/python/blob/master/exercises/rna-transcription/example.py) to remove Python 2 compatiblity noise: +Taken from the existing [example.py](https://github.com/exercism/python/blob/main/exercises/practice/rna-transcription/.meta/example.py): ```python DNA_TO_RNA = str.maketrans("AGCT", "UCGA")