Skip to content

Drop Py < 3.7 & Don't use lru_cache #23

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

Merged
merged 3 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 3 additions & 27 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,13 @@ jobs:
max-parallel: 10
matrix:
python-version:
- "3.5"
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "3.10"
pytest-version:
- "~=6.0.0"
- "~=6.1.0"
- "~=6.2.0"
- "~=7.0.0"
- "~=7.1.0"
exclude:
- {"python-version": "3.5", "pytest-version": "~=6.2.0"}
- {"python-version": "3.5", "pytest-version": "~=7.0.0"}
- {"python-version": "3.5", "pytest-version": "~=7.1.0"}
- {"python-version": "3.6", "pytest-version": "~=7.1.0"}
- {"python-version": "3.10", "pytest-version": "~=6.0.0"}
- {"python-version": "3.10", "pytest-version": "~=6.1.0"}
- "~=7.2.0"

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -277,19 +265,13 @@ jobs:
max-parallel: 10
matrix:
python-version:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "3.10"
pytest-version:
- "~=6.2.0"
- "~=7.0.0"
- "~=7.1.0"
exclude:
- {"python-version": "3.6", "pytest-version": "~=7.1.0"}
- {"python-version": "3.10", "pytest-version": "~=6.0.0"}
- {"python-version": "3.10", "pytest-version": "~=6.1.0"}
- "~=7.2.0"

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -423,19 +405,13 @@ jobs:
max-parallel: 10
matrix:
python-version:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "3.10"
pytest-version:
- "~=6.2.0"
- "~=7.0.0"
- "~=7.1.0"
exclude:
- {"python-version": "3.6", "pytest-version": "~=7.1.0"}
- {"python-version": "3.10", "pytest-version": "~=6.0.0"}
- {"python-version": "3.10", "pytest-version": "~=6.1.0"}
- "~=7.2.0"

steps:
- uses: actions/checkout@v2
Expand Down
34 changes: 9 additions & 25 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
minimum_pre_commit_version: 1.15.2
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.4.0
hooks:
- id: check-merge-conflict # Check for files that contain merge conflict strings.
- id: trailing-whitespace # Trims trailing whitespace.
Expand Down Expand Up @@ -36,32 +36,16 @@ repos:
language: system
# <---- Local Hooks ------------------------------------------------------------------------------------------------

# ----- Remove Typing - Py3.5 Support ---------------------------------------------------------------------------->
- repo: https://github.com/s0undt3ch/downgrade-source
rev: v2.1.0
hooks:
- id: downgrade-source
name: Downgrade source code into a separate package to support Py3.5
files: ^src/.*\.py$
exclude: ^src/pytestskipmarkers/((__init__|version|utils/__init__)\.py|downgraded/.*\.py)$
args:
- --target-version=3.5
- --pkg-path=src/pytestskipmarkers
- --skip-checker=nounusableimports
- --skip-checker=nostarimports
# <---- Remove Typing - Py3.5 Support -----------------------------------------------------------------------------

# ----- Formatting ------------------------------------------------------------------------------------------------>
- repo: https://github.com/asottile/pyupgrade
rev: v2.32.0
rev: v3.3.1
hooks:
- id: pyupgrade
name: Rewrite Code to be Py3.5+
args: [--py3-plus]
exclude: ^src/pytestskipmarkers/downgraded/.*\.py$
name: Rewrite Code to be Py3.7+
args: [--py37-plus]

- repo: https://github.com/asottile/reorder_python_imports
rev: v3.0.1
rev: v3.9.0
hooks:
- id: reorder-python-imports
args: [
Expand All @@ -71,7 +55,7 @@ repos:
exclude: ^src/pytestskipmarkers/(version.py|downgraded/.*)$

- repo: https://github.com/psf/black
rev: 22.3.0
rev: 22.12.0
hooks:
- id: black
args: [-l 100]
Expand Down Expand Up @@ -111,7 +95,7 @@ repos:

# ----- Code Analysis --------------------------------------------------------------------------------------------->
- repo: https://github.com/pycqa/flake8
rev: '4.0.1'
rev: '6.0.0'
hooks:
- id: flake8
exclude: ^(src/pytestskipmarkers/(downgraded/.*|version\.py)|\.pre-commit-hooks/.*\.py)$
Expand All @@ -121,7 +105,7 @@ repos:
- flake8-typing-imports

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.942
rev: v0.991
hooks:
- id: mypy
name: Run mypy against source
Expand All @@ -134,7 +118,7 @@ repos:
- types-setuptools

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.942
rev: v0.991
hooks:
- id: mypy
name: Run mypy against tests
Expand Down
1 change: 1 addition & 0 deletions changelog/21.improvement.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Don't cache the functions in `pytestskipmarkers.utils.platform`
1 change: 1 addition & 0 deletions changelog/22.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Drop support for python versions older than 3.7
1 change: 1 addition & 0 deletions changelog/23.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated pre-commit hook versions
24 changes: 11 additions & 13 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def tests(session):
# itself does not get upgraded
pytest_requirements = []
if not pytest_version_requirement.startswith("pytest"):
pytest_version_requirement = "pytest{}".format(pytest_version_requirement)
pytest_version_requirement = f"pytest{pytest_version_requirement}"
pytest_requirements.append(pytest_version_requirement)
if pytest_version_requirement.startswith("pytest~=6"):
pytest_requirements.append("pytest-subtests<0.7.0")
Expand Down Expand Up @@ -172,10 +172,10 @@ def tests(session):
args = [
"--rootdir",
str(REPO_ROOT),
"--log-file={}".format(RUNTESTS_LOGFILE),
f"--log-file={RUNTESTS_LOGFILE}",
"--log-file-level=debug",
"--show-capture=no",
"--junitxml={}".format(JUNIT_REPORT),
f"--junitxml={JUNIT_REPORT}",
"--showlocals",
"--strict-markers",
"-ra",
Expand Down Expand Up @@ -222,7 +222,7 @@ def tests(session):
"--include=src/pytestskipmarkers/*,tests/*",
]
if pytest_version(session) >= (6, 2):
cmdline.append("--fail-under={}".format(COVERAGE_FAIL_UNDER_PERCENT))
cmdline.append(f"--fail-under={COVERAGE_FAIL_UNDER_PERCENT}")
session.run(*cmdline)
finally:
if COVERAGE_REPORT_DB.exists():
Expand All @@ -239,7 +239,7 @@ def _lint(session, rcfile, flags, paths):
session.run("pylint", "--version")
pylint_report_path = os.environ.get("PYLINT_REPORT")

cmd_args = ["pylint", "--rcfile={}".format(rcfile)] + list(flags) + list(paths)
cmd_args = ["pylint", f"--rcfile={rcfile}"] + list(flags) + list(paths)

stdout = tempfile.TemporaryFile(mode="w+b")
try:
Expand All @@ -264,8 +264,8 @@ def lint(session):
"""
Run PyLint against Salt and it's test suite. Set PYLINT_REPORT to a path to capture output.
"""
session.notify("lint-code-{}".format(session.python))
session.notify("lint-tests-{}".format(session.python))
session.notify(f"lint-code-{session.python}")
session.notify(f"lint-tests-{session.python}")


@nox.session(python="3", name="lint-code")
Expand Down Expand Up @@ -421,7 +421,7 @@ def changelog(session, draft):
stderr=None,
).strip()

town_cmd = ["towncrier", "build", "--version={}".format(version)]
town_cmd = ["towncrier", "build", f"--version={version}"]
if draft:
town_cmd.append("--draft")
session.run(*town_cmd)
Expand All @@ -444,7 +444,7 @@ def release(session):
version = session.posargs[0]
try:
session.log("Generating temporary %s tag", version)
session.run("git", "tag", "-as", version, "-m", "Release {}".format(version), external=True)
session.run("git", "tag", "-as", version, "-m", f"Release {version}", external=True)
changelog(session, draft=False)
except CommandFailed:
session.error("Failed to generate the temporary tag")
Expand All @@ -456,16 +456,14 @@ def release(session):
"commit",
"-a",
"-m",
"Generate Changelog for version {}".format(version),
f"Generate Changelog for version {version}",
external=True,
)
except CommandFailed:
session.error("Failed to generate the release changelog")
try:
session.log("Overwriting temporary %s tag", version)
session.run(
"git", "tag", "-fas", version, "-m", "Release {}".format(version), external=True
)
session.run("git", "tag", "-fas", version, "-m", f"Release {version}", external=True)
except CommandFailed:
session.error("Failed to overwrite the temporary tag")
session.warn("Don't forget to push the newly created tag")
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pytest>=6.0.0
pytest>=7.1.0
attrs>=19.2.0
pywin32; sys_platform == "win32"
distro
7 changes: 4 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ classifiers =
Programming Language :: Cython
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Development Status :: 5 - Production/Stable
Framework :: Pytest
Typing :: Typed
Expand All @@ -33,7 +34,7 @@ include_package_data = True
package_dir =
=src
packages = find:
python_requires = >= 3.5.2
python_requires = >= 3.7
setup_requires =
setuptools>=50.3.2
setuptools_scm[toml]>=3.4
Expand Down
37 changes: 0 additions & 37 deletions src/pytestskipmarkers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,10 @@
# SPDX-License-Identifier: Apache-2.0
#
# type: ignore
import importlib
import pathlib
import re
import sys


USE_DOWNGRADED_TRANSPILED_CODE = sys.version_info < (3, 6)


if USE_DOWNGRADED_TRANSPILED_CODE:
# We generated downgraded code just for Py3.5
# Let's just import from those modules instead

class NoTypingImporter:
"""
Meta importer to redirect imports on Py35.
"""

NO_REDIRECT_NAMES = (
"pytestskipmarkers.version",
"pytestskipmarkers.downgraded",
)

def find_module(self, module_name, package_path=None): # noqa: D102
if module_name.startswith(self.NO_REDIRECT_NAMES):
return None
if not module_name.startswith("pytestskipmarkers"):
return None
return self

def load_module(self, name): # noqa: D102
if not name.startswith(self.NO_REDIRECT_NAMES):
mod = importlib.import_module("pytestskipmarkers.downgraded.{}".format(name[18:]))
else:
mod = importlib.import_module(name)
sys.modules[name] = mod
return mod

# Try our importer first
sys.meta_path = [NoTypingImporter()] + sys.meta_path

try:
from .version import __version__
except ImportError: # pragma: no cover
Expand Down
Empty file.
Loading