]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Remove redundant code for EOL Python <= 3.6
authorHugo van Kemenade <hugovk@users.noreply.github.com>
Thu, 6 Jan 2022 17:14:33 +0000 (12:14 -0500)
committersqla-tester <sqla-tester@sqlalchemy.org>
Thu, 6 Jan 2022 17:14:33 +0000 (12:14 -0500)
<!-- Provide a general summary of your proposed changes in the Title field above -->

### Description
<!-- Describe your changes in detail -->

There's a few bits and pieces of code to support Python <= 3.6 which are no longer needed and can be removed, to slightly simplify the codebase.

### Checklist
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

This pull request is:

- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [x] A short code fix
- please include the issue number, and create an issue if none exists, which
  must include a complete example of the issue.  one line code fixes without an
  issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.   one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
  include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.

**Have a nice day!**

Closes: #7544
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7544
Pull-request-sha: 282b4a91282902a57807aa2541b75b272b547127

Change-Id: I9ddf15fcf72551d52e3f027f337c7fee4aa9083b

.github/workflows/create-wheels.yaml
README.unittests.rst
examples/space_invaders/space_invaders.py
lib/sqlalchemy/sql/lambdas.py
lib/sqlalchemy/testing/plugin/pytestplugin.py
test/ext/test_associationproxy.py
test/requirements.py

index c6eab3148de5406a2e6df675277b7d85b458074e..4d54867b9f7c11529c31636261e64ba4ba949213 100644 (file)
@@ -76,9 +76,6 @@ jobs:
           pip install -f dist --no-index sqlalchemy
 
       - name: Check c extensions
-        # on windows in python 2.7 the cextension fail to build.
-        # for python 2.7 visual studio 9 is missing
-        if: matrix.os != 'windows-latest' || matrix.python-version != '2.7'
         run: |
           python -c 'from sqlalchemy.util import has_compiled_ext; assert has_compiled_ext()'
 
@@ -153,7 +150,7 @@ jobs:
         run: |
           (cat setup.cfg) | %{$_ -replace "tag_build.?=.?dev",""} | set-content setup.cfg
 
-      - name: Create wheel for manylinux1 and manylinux2010 for py3
+      - name: Create wheel for manylinux1 and manylinux2010
         # this step uses the image provided by pypa here https://github.com/pypa/manylinux to generate the wheels on linux
         # the action uses the image for manylinux2010 but can generate also a manylinux1 wheel
         # change the tag of this image to change the image used
@@ -166,7 +163,7 @@ jobs:
           # `--no-deps` is used to only generate the wheel for the current library. Redundant in sqlalchemy since it has no dependencies
           pip-wheel-args: "-w ./dist -v --no-deps"
 
-      - name: Create wheel for manylinux2014 for py3
+      - name: Create wheel for manylinux2014
         # this step uses the image provided by pypa here https://github.com/pypa/manylinux to generate the wheels on linux
         # the action uses the image for manylinux2010 but can generate also a manylinux1 wheel
         # change the tag of this image to change the image used
index 32b7446123875cf8113c93e365ea80557a905d5e..539df5adf2e96e7f340f7e00800f01bfc47ccc38 100644 (file)
@@ -135,7 +135,7 @@ with the tox runner also::
     [db]
     postgresql=postgresql+psycopg2://username:pass@hostname/dbname
 
-Now when we run ``tox -e py27-postgresql``, it will use our custom URL instead
+Now when we run ``tox -e py38-postgresql``, it will use our custom URL instead
 of the fixed one in setup.cfg.
 
 Database Configuration
index 1690145db25f12965e58f1fd93e41f3db2237529..bc97d62e25195fafdee7a4b7d80ea575085314c4 100644 (file)
@@ -2,7 +2,6 @@ import curses
 import logging
 import random
 import re
-import sys
 import textwrap
 import time
 
@@ -20,11 +19,6 @@ from sqlalchemy.orm import relationship
 from sqlalchemy.orm import Session
 
 
-_PY3 = sys.version_info > (3, 0)
-if _PY3:
-    xrange = range
-
-
 logging.basicConfig(
     filename="space_invaders.log",
     format="%(asctime)s,%(msecs)03d %(levelname)-5.5s %(message)s",
@@ -158,7 +152,7 @@ class GlyphCoordinate(Base):
         glyph = self.glyph
         data = glyph.glyph_for_state(self, state)
         for color, char in [
-            (data[i], data[i + 1]) for i in xrange(0, len(data), 2)
+            (data[i], data[i + 1]) for i in range(0, len(data), 2)
         ]:
 
             x = self.x + col
@@ -190,7 +184,7 @@ class GlyphCoordinate(Base):
         glyph = self.glyph
         x = min(max(self.x, 0), MAX_X)
         width = min(glyph.width, MAX_X - x) or 1
-        for y_a in xrange(self.y, self.y + glyph.height):
+        for y_a in range(self.y, self.y + glyph.height):
             y = y_a
             window.addstr(y + VERT_PADDING, x + HORIZ_PADDING, " " * width)
 
@@ -455,9 +449,9 @@ def init_positions(session):
         ("enemy1", 10),
     )
     for (ship_vert, (etype, score)) in zip(
-        xrange(5, 30, ENEMY_VERT_SPACING), arrangement
+        range(5, 30, ENEMY_VERT_SPACING), arrangement
     ):
-        for ship_horiz in xrange(0, 50, 10):
+        for ship_horiz in range(0, 50, 10):
             session.add(
                 GlyphCoordinate(
                     session, etype, ship_horiz, ship_vert, score=score
index b2c36667105a8ebe354c87b0c991a3833d997819..8af727bbe88bf96da2e6e9f454920889b49c8e09 100644 (file)
@@ -8,7 +8,6 @@
 import collections.abc as collections_abc
 import itertools
 import operator
-import sys
 import types
 import weakref
 
@@ -1113,9 +1112,8 @@ class AnalyzedFunction:
         func = type(f)(
             f.__code__, globals_, f.__name__, f.__defaults__, closure
         )
-        if sys.version_info >= (3,):
-            func.__annotations__ = f.__annotations__
-            func.__kwdefaults__ = f.__kwdefaults__
+        func.__annotations__ = f.__annotations__
+        func.__kwdefaults__ = f.__kwdefaults__
         func.__doc__ = f.__doc__
         func.__module__ = f.__module__
 
index 8679a9f12b47ae85dd71079ad5e0f581b8aa5a07..7a62ad0083c66b251a0baefaaedc68decd138e2e 100644 (file)
@@ -13,7 +13,6 @@ import itertools
 import operator
 import os
 import re
-import sys
 
 import pytest
 
@@ -528,13 +527,6 @@ def setup_test_methods(request):
     #    depending on the flags defined by the test class)
 
 
-def getargspec(fn):
-    if sys.version_info.major == 3:
-        return inspect.getfullargspec(fn)
-    else:
-        return inspect.getargspec(fn)
-
-
 def _pytest_fn_decorator(target):
     """Port of langhelpers.decorator with pytest-specific tricks."""
 
@@ -611,12 +603,8 @@ class PytestFixtureFunctions(plugin_base.FixtureFunctions):
         """
         from sqlalchemy.testing import exclusions
 
-        if sys.version_info.major == 3:
-            if len(arg_sets) == 1 and hasattr(arg_sets[0], "__next__"):
-                arg_sets = list(arg_sets[0])
-        else:
-            if len(arg_sets) == 1 and hasattr(arg_sets[0], "next"):
-                arg_sets = list(arg_sets[0])
+        if len(arg_sets) == 1 and hasattr(arg_sets[0], "__next__"):
+            arg_sets = list(arg_sets[0])
 
         argnames = kw.pop("argnames", None)
 
@@ -711,7 +699,7 @@ class PytestFixtureFunctions(plugin_base.FixtureFunctions):
                 return fn
             else:
                 if argnames is None:
-                    _argnames = getargspec(fn).args[1:]
+                    _argnames = inspect.getfullargspec(fn).args[1:]
                 else:
                     _argnames = re.split(r", *", argnames)
 
index 3fa7b4999f71a8b519c12d439fb272e55499a67e..583898ce9f463bba9c22c4c49df09969c953c877 100644 (file)
@@ -734,7 +734,6 @@ class SetTest(_CollectionOperations):
             self.assert_((p1.children > other) == (control > other))
             self.assert_((p1.children >= other) == (control >= other))
 
-    @testing.requires.python_fixed_issue_8743
     def test_set_comparison_empty_to_empty(self):
         # test issue #3265 which was fixed in Python version 2.7.8
         Parent = self.classes.Parent
index 3934dd23fc596e6edd55f005f942b38eac7a7b5e..37aea52e1b403f0f6e6c5a1ed458df7f7ee8131f 100644 (file)
@@ -3,8 +3,6 @@
 
 """
 
-import sys
-
 from sqlalchemy import exc
 from sqlalchemy.sql import sqltypes
 from sqlalchemy.sql import text
@@ -1393,26 +1391,6 @@ class DefaultRequirements(SuiteRequirements):
             has_fastexecutemany, "only on pyodbc > 4.0.19 w/ msodbc driver"
         )
 
-    @property
-    def python_fixed_issue_8743(self):
-        return exclusions.skip_if(
-            lambda: sys.version_info < (2, 7, 8),
-            "Python issue 8743 fixed in Python 2.7.8",
-        )
-
-    @property
-    def granular_timezone(self):
-        """the datetime.timezone class, or SQLAlchemy's port, supports
-        seconds and microseconds.
-
-        SQLAlchemy ported the Python 3.7 version for Python 2, so
-        it passes on that.  For Python 3.6 and earlier, it is not supported.
-
-        """
-        return exclusions.skip_if(
-            lambda: sys.version_info >= (3,) and sys.version_info < (3, 7)
-        )
-
     @property
     def selectone(self):
         """target driver must support the literal statement 'select 1'"""