Commit 5bad73cd by David Hotham Committed by GitHub

drop support for python 3.7 (#7674)

parent 68b88e53
...@@ -12,7 +12,6 @@ test_task: ...@@ -12,7 +12,6 @@ test_task:
# avoid failures on tests that depend on it. # avoid failures on tests that depend on it.
SHELL: sh SHELL: sh
matrix: matrix:
- PYTHON: python3.7
- PYTHON: python3.8 - PYTHON: python3.8
- PYTHON: python3.9 - PYTHON: python3.9
- PYTHON: python3.10 - PYTHON: python3.10
......
...@@ -28,7 +28,7 @@ jobs: ...@@ -28,7 +28,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [Ubuntu, macOS, Windows] os: [Ubuntu, macOS, Windows]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] python-version: ["3.8", "3.9", "3.10", "3.11"]
include: include:
- os: Ubuntu - os: Ubuntu
image: ubuntu-22.04 image: ubuntu-22.04
......
...@@ -28,6 +28,6 @@ jobs: ...@@ -28,6 +28,6 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [Ubuntu, macOS, Windows] os: [Ubuntu, macOS, Windows]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] python-version: ["3.8", "3.9", "3.10", "3.11"]
steps: steps:
- run: exit 0 - run: exit 0
...@@ -18,7 +18,7 @@ Poetry offers a lockfile to ensure repeatable installs, and can build your proje ...@@ -18,7 +18,7 @@ Poetry offers a lockfile to ensure repeatable installs, and can build your proje
## System requirements ## System requirements
Poetry requires **Python 3.7+**. It is multi-platform and the goal is to make it work equally well Poetry requires **Python 3.8+**. It is multi-platform and the goal is to make it work equally well
on Linux, macOS and Windows. on Linux, macOS and Windows.
## Installation ## Installation
......
...@@ -23,18 +23,6 @@ tests = ["attrs[tests-no-zope]", "zope-interface"] ...@@ -23,18 +23,6 @@ tests = ["attrs[tests-no-zope]", "zope-interface"]
tests-no-zope = ["cloudpickle", "hypothesis", "mypy (>=1.1.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] tests-no-zope = ["cloudpickle", "hypothesis", "mypy (>=1.1.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"]
[[package]] [[package]]
name = "backports-cached-property"
version = "1.0.2"
description = "cached_property() - computed once per instance, cached as attribute"
category = "main"
optional = false
python-versions = ">=3.6.0"
files = [
{file = "backports.cached-property-1.0.2.tar.gz", hash = "sha256:9306f9eed6ec55fd156ace6bc1094e2c86fae5fb2bf07b6a9c00745c656e75dd"},
{file = "backports.cached_property-1.0.2-py3-none-any.whl", hash = "sha256:baeb28e1cd619a3c9ab8941431fe34e8490861fb998c6c4590693d50171db0cc"},
]
[[package]]
name = "build" name = "build"
version = "0.10.0" version = "0.10.0"
description = "A simple, correct Python build frontend" description = "A simple, correct Python build frontend"
...@@ -48,7 +36,6 @@ files = [ ...@@ -48,7 +36,6 @@ files = [
[package.dependencies] [package.dependencies]
colorama = {version = "*", markers = "os_name == \"nt\""} colorama = {version = "*", markers = "os_name == \"nt\""}
importlib-metadata = {version = ">=0.22", markers = "python_version < \"3.8\""}
packaging = ">=19.0" packaging = ">=19.0"
pyproject_hooks = "*" pyproject_hooks = "*"
tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""}
...@@ -530,7 +517,6 @@ files = [ ...@@ -530,7 +517,6 @@ files = [
] ]
[package.dependencies] [package.dependencies]
typing-extensions = {version = "*", markers = "python_version <= \"3.7\""}
urllib3 = ">=1.25" urllib3 = ">=1.25"
[package.extras] [package.extras]
...@@ -658,7 +644,6 @@ files = [ ...@@ -658,7 +644,6 @@ files = [
] ]
[package.dependencies] [package.dependencies]
typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""}
zipp = ">=0.5" zipp = ">=0.5"
[package.extras] [package.extras]
...@@ -758,11 +743,9 @@ files = [ ...@@ -758,11 +743,9 @@ files = [
[package.dependencies] [package.dependencies]
attrs = ">=17.4.0" attrs = ">=17.4.0"
importlib-metadata = {version = "*", markers = "python_version < \"3.8\""}
importlib-resources = {version = ">=1.4.0", markers = "python_version < \"3.9\""} importlib-resources = {version = ">=1.4.0", markers = "python_version < \"3.9\""}
pkgutil-resolve-name = {version = ">=1.3.10", markers = "python_version < \"3.9\""} pkgutil-resolve-name = {version = ">=1.3.10", markers = "python_version < \"3.9\""}
pyrsistent = ">=0.14.0,<0.17.0 || >0.17.0,<0.17.1 || >0.17.1,<0.17.2 || >0.17.2" pyrsistent = ">=0.14.0,<0.17.0 || >0.17.0,<0.17.1 || >0.17.1,<0.17.2 || >0.17.2"
typing-extensions = {version = "*", markers = "python_version < \"3.8\""}
[package.extras] [package.extras]
format = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-validator", "rfc3987", "uri-template", "webcolors (>=1.11)"] format = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-validator", "rfc3987", "uri-template", "webcolors (>=1.11)"]
...@@ -929,7 +912,6 @@ files = [ ...@@ -929,7 +912,6 @@ files = [
[package.dependencies] [package.dependencies]
mypy-extensions = ">=1.0.0" mypy-extensions = ">=1.0.0"
tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""}
typed-ast = {version = ">=1.4.0,<2", markers = "python_version < \"3.8\""}
typing-extensions = ">=3.10" typing-extensions = ">=3.10"
[package.extras] [package.extras]
...@@ -1046,9 +1028,6 @@ files = [ ...@@ -1046,9 +1028,6 @@ files = [
{file = "platformdirs-3.5.1.tar.gz", hash = "sha256:412dae91f52a6f84830f39a8078cecd0e866cb72294a5c66808e74d5e88d251f"}, {file = "platformdirs-3.5.1.tar.gz", hash = "sha256:412dae91f52a6f84830f39a8078cecd0e866cb72294a5c66808e74d5e88d251f"},
] ]
[package.dependencies]
typing-extensions = {version = ">=4.5", markers = "python_version < \"3.8\""}
[package.extras] [package.extras]
docs = ["furo (>=2023.3.27)", "proselint (>=0.13)", "sphinx (>=6.2.1)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)"] docs = ["furo (>=2023.3.27)", "proselint (>=0.13)", "sphinx (>=6.2.1)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)"]
test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.3.1)", "pytest-cov (>=4)", "pytest-mock (>=3.10)"] test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.3.1)", "pytest-cov (>=4)", "pytest-mock (>=3.10)"]
...@@ -1065,9 +1044,6 @@ files = [ ...@@ -1065,9 +1044,6 @@ files = [
{file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"}, {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"},
] ]
[package.dependencies]
importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""}
[package.extras] [package.extras]
dev = ["pre-commit", "tox"] dev = ["pre-commit", "tox"]
testing = ["pytest", "pytest-benchmark"] testing = ["pytest", "pytest-benchmark"]
...@@ -1084,9 +1060,6 @@ files = [ ...@@ -1084,9 +1060,6 @@ files = [
{file = "poetry_core-1.6.0.tar.gz", hash = "sha256:a9c7296a12d6c8e4f8aa50a66ef3c967b2b50fba634da144d358e676fad9989f"}, {file = "poetry_core-1.6.0.tar.gz", hash = "sha256:a9c7296a12d6c8e4f8aa50a66ef3c967b2b50fba634da144d358e676fad9989f"},
] ]
[package.dependencies]
importlib-metadata = {version = ">=1.7.0", markers = "python_version < \"3.8\""}
[[package]] [[package]]
name = "poetry-plugin-export" name = "poetry-plugin-export"
version = "1.3.1" version = "1.3.1"
...@@ -1118,7 +1091,6 @@ files = [ ...@@ -1118,7 +1091,6 @@ files = [
[package.dependencies] [package.dependencies]
cfgv = ">=2.0.0" cfgv = ">=2.0.0"
identify = ">=1.0.0" identify = ">=1.0.0"
importlib-metadata = {version = "*", markers = "python_version < \"3.8\""}
nodeenv = ">=0.11.1" nodeenv = ">=0.11.1"
pyyaml = ">=5.1" pyyaml = ">=5.1"
virtualenv = ">=20.10.0" virtualenv = ">=20.10.0"
...@@ -1241,7 +1213,6 @@ files = [ ...@@ -1241,7 +1213,6 @@ files = [
[package.dependencies] [package.dependencies]
colorama = {version = "*", markers = "sys_platform == \"win32\""} colorama = {version = "*", markers = "sys_platform == \"win32\""}
exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""}
importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""}
iniconfig = "*" iniconfig = "*"
packaging = "*" packaging = "*"
pluggy = ">=0.12,<2.0" pluggy = ">=0.12,<2.0"
...@@ -1638,40 +1609,6 @@ files = [ ...@@ -1638,40 +1609,6 @@ files = [
] ]
[[package]] [[package]]
name = "typed-ast"
version = "1.5.4"
description = "a fork of Python 2 and 3 ast modules with type comment support"
category = "dev"
optional = false
python-versions = ">=3.6"
files = [
{file = "typed_ast-1.5.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:669dd0c4167f6f2cd9f57041e03c3c2ebf9063d0757dc89f79ba1daa2bfca9d4"},
{file = "typed_ast-1.5.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:211260621ab1cd7324e0798d6be953d00b74e0428382991adfddb352252f1d62"},
{file = "typed_ast-1.5.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:267e3f78697a6c00c689c03db4876dd1efdfea2f251a5ad6555e82a26847b4ac"},
{file = "typed_ast-1.5.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:c542eeda69212fa10a7ada75e668876fdec5f856cd3d06829e6aa64ad17c8dfe"},
{file = "typed_ast-1.5.4-cp310-cp310-win_amd64.whl", hash = "sha256:a9916d2bb8865f973824fb47436fa45e1ebf2efd920f2b9f99342cb7fab93f72"},
{file = "typed_ast-1.5.4-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:79b1e0869db7c830ba6a981d58711c88b6677506e648496b1f64ac7d15633aec"},
{file = "typed_ast-1.5.4-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a94d55d142c9265f4ea46fab70977a1944ecae359ae867397757d836ea5a3f47"},
{file = "typed_ast-1.5.4-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:183afdf0ec5b1b211724dfef3d2cad2d767cbefac291f24d69b00546c1837fb6"},
{file = "typed_ast-1.5.4-cp36-cp36m-win_amd64.whl", hash = "sha256:639c5f0b21776605dd6c9dbe592d5228f021404dafd377e2b7ac046b0349b1a1"},
{file = "typed_ast-1.5.4-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:cf4afcfac006ece570e32d6fa90ab74a17245b83dfd6655a6f68568098345ff6"},
{file = "typed_ast-1.5.4-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ed855bbe3eb3715fca349c80174cfcfd699c2f9de574d40527b8429acae23a66"},
{file = "typed_ast-1.5.4-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:6778e1b2f81dfc7bc58e4b259363b83d2e509a65198e85d5700dfae4c6c8ff1c"},
{file = "typed_ast-1.5.4-cp37-cp37m-win_amd64.whl", hash = "sha256:0261195c2062caf107831e92a76764c81227dae162c4f75192c0d489faf751a2"},
{file = "typed_ast-1.5.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:2efae9db7a8c05ad5547d522e7dbe62c83d838d3906a3716d1478b6c1d61388d"},
{file = "typed_ast-1.5.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7d5d014b7daa8b0bf2eaef684295acae12b036d79f54178b92a2b6a56f92278f"},
{file = "typed_ast-1.5.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:370788a63915e82fd6f212865a596a0fefcbb7d408bbbb13dea723d971ed8bdc"},
{file = "typed_ast-1.5.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:4e964b4ff86550a7a7d56345c7864b18f403f5bd7380edf44a3c1fb4ee7ac6c6"},
{file = "typed_ast-1.5.4-cp38-cp38-win_amd64.whl", hash = "sha256:683407d92dc953c8a7347119596f0b0e6c55eb98ebebd9b23437501b28dcbb8e"},
{file = "typed_ast-1.5.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:4879da6c9b73443f97e731b617184a596ac1235fe91f98d279a7af36c796da35"},
{file = "typed_ast-1.5.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3e123d878ba170397916557d31c8f589951e353cc95fb7f24f6bb69adc1a8a97"},
{file = "typed_ast-1.5.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ebd9d7f80ccf7a82ac5f88c521115cc55d84e35bf8b446fcd7836eb6b98929a3"},
{file = "typed_ast-1.5.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:98f80dee3c03455e92796b58b98ff6ca0b2a6f652120c263efdba4d6c5e58f72"},
{file = "typed_ast-1.5.4-cp39-cp39-win_amd64.whl", hash = "sha256:0fdbcf2fef0ca421a3f5912555804296f0b0960f0418c440f5d6d3abb549f3e1"},
{file = "typed_ast-1.5.4.tar.gz", hash = "sha256:39e21ceb7388e4bb37f4c679d72707ed46c2fbf2a5609b8b8ebc4b067d977df2"},
]
[[package]]
name = "types-html5lib" name = "types-html5lib"
version = "1.1.11.14" version = "1.1.11.14"
description = "Typing stubs for html5lib" description = "Typing stubs for html5lib"
...@@ -1726,7 +1663,7 @@ files = [ ...@@ -1726,7 +1663,7 @@ files = [
name = "typing-extensions" name = "typing-extensions"
version = "4.5.0" version = "4.5.0"
description = "Backported and Experimental Type Hints for Python 3.7+" description = "Backported and Experimental Type Hints for Python 3.7+"
category = "main" category = "dev"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
...@@ -1766,7 +1703,6 @@ files = [ ...@@ -1766,7 +1703,6 @@ files = [
[package.dependencies] [package.dependencies]
distlib = ">=0.3.6,<1" distlib = ">=0.3.6,<1"
filelock = ">=3.11,<4" filelock = ">=3.11,<4"
importlib-metadata = {version = ">=6.4.1", markers = "python_version < \"3.8\""}
platformdirs = ">=3.2,<4" platformdirs = ">=3.2,<4"
[package.extras] [package.extras]
...@@ -1888,5 +1824,5 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more ...@@ -1888,5 +1824,5 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = "^3.7" python-versions = "^3.8"
content-hash = "88510d026496be61125bc3157ece9584978ce58bf42fb551ca6d03066b8d8c61" content-hash = "0eccb38c0af361232f1dadebed6e98fdd7e4c9f7238accf0c634121af0afcb88"
...@@ -30,11 +30,10 @@ Changelog = "https://python-poetry.org/history/" ...@@ -30,11 +30,10 @@ Changelog = "https://python-poetry.org/history/"
# Requirements # Requirements
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.7" python = "^3.8"
poetry-core = "1.6.0" poetry-core = "1.6.0"
poetry-plugin-export = "^1.3.1" poetry-plugin-export = "^1.3.1"
"backports.cached-property" = { version = "^1.0.2", python = "<3.8" }
build = "^0.10.0" build = "^0.10.0"
cachecontrol = { version = "^0.12.9", extras = ["filecache"] } cachecontrol = { version = "^0.12.9", extras = ["filecache"] }
cleo = "^2.0.0" cleo = "^2.0.0"
...@@ -77,14 +76,12 @@ pytest-cov = "^4.0" ...@@ -77,14 +76,12 @@ pytest-cov = "^4.0"
pytest-mock = "^3.9" pytest-mock = "^3.9"
pytest-randomly = "^3.12" pytest-randomly = "^3.12"
pytest-xdist = { version = "^3.1", extras = ["psutil"] } pytest-xdist = { version = "^3.1", extras = ["psutil"] }
zipp = { version = "^3.4", python = "<3.8" }
[tool.poetry.group.typing.dependencies] [tool.poetry.group.typing.dependencies]
mypy = ">=1.0" mypy = ">=1.0"
types-html5lib = ">=1.1.9" types-html5lib = ">=1.1.9"
types-jsonschema = ">=4.9.0" types-jsonschema = ">=4.9.0"
types-requests = ">=2.28.8" types-requests = ">=2.28.8"
typing-extensions = { version = "^4.0.0", python = "<3.8" }
# only used in github actions # only used in github actions
[tool.poetry.group.github-actions] [tool.poetry.group.github-actions]
...@@ -106,7 +103,7 @@ fix = true ...@@ -106,7 +103,7 @@ fix = true
unfixable = [ unfixable = [
"ERA", # do not autoremove commented out code "ERA", # do not autoremove commented out code
] ]
target-version = "py37" target-version = "py38"
line-length = 88 line-length = 88
extend-select = [ extend-select = [
"B", # flake8-bugbear "B", # flake8-bugbear
...@@ -146,9 +143,8 @@ known-first-party = ["poetry"] ...@@ -146,9 +143,8 @@ known-first-party = ["poetry"]
known-third-party = ["poetry.core"] known-third-party = ["poetry.core"]
required-imports = ["from __future__ import annotations"] required-imports = ["from __future__ import annotations"]
[tool.black] [tool.black]
target-version = ['py37'] target-version = ['py38']
preview = true preview = true
force-exclude = ''' force-exclude = '''
.*/setup\.py$ .*/setup\.py$
......
...@@ -766,10 +766,7 @@ class Executor: ...@@ -766,10 +766,7 @@ class Executor:
link link
) )
cached_file = cache_directory.joinpath(link.filename) cached_file = cache_directory.joinpath(link.filename)
# We can't use unlink(missing_ok=True) because it's not available cached_file.unlink(missing_ok=True)
# prior to Python 3.8
if cached_file.exists():
cached_file.unlink()
raise raise
...@@ -897,9 +894,7 @@ class Executor: ...@@ -897,9 +894,7 @@ class Executor:
) in self._env.site_packages.find_distribution_direct_url_json_files( ) in self._env.site_packages.find_distribution_direct_url_json_files(
distribution_name=package.name, writable_only=True distribution_name=package.name, writable_only=True
): ):
# We can't use unlink(missing_ok=True) because it's not always available direct_url_json.unlink(missing_ok=True)
if direct_url_json.exists():
direct_url_json.unlink()
return return
url_reference: dict[str, Any] | None = None url_reference: dict[str, Any] | None = None
......
...@@ -132,9 +132,7 @@ class EditableBuilder(Builder): ...@@ -132,9 +132,7 @@ class EditableBuilder(Builder):
f" - Removing existing <c2>{file.name}</c2> from <b>{file.parent}</b>" f" - Removing existing <c2>{file.name}</c2> from <b>{file.parent}</b>"
f" for {self._poetry.file.path.parent}" f" for {self._poetry.file.path.parent}"
) )
# We can't use unlink(missing_ok=True) because it's not always available file.unlink(missing_ok=True)
if file.exists():
file.unlink()
try: try:
pth_file = self._env.site_packages.write_text( pth_file = self._env.site_packages.write_text(
......
...@@ -3,6 +3,7 @@ from __future__ import annotations ...@@ -3,6 +3,7 @@ from __future__ import annotations
import logging import logging
import re import re
from functools import cached_property
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import DefaultDict from typing import DefaultDict
from typing import List from typing import List
...@@ -11,7 +12,6 @@ from poetry.core.constraints.version import Version ...@@ -11,7 +12,6 @@ from poetry.core.constraints.version import Version
from poetry.core.packages.package import Package from poetry.core.packages.package import Package
from poetry.core.version.exceptions import InvalidVersion from poetry.core.version.exceptions import InvalidVersion
from poetry.utils._compat import cached_property
from poetry.utils.patterns import sdist_file_re from poetry.utils.patterns import sdist_file_re
from poetry.utils.patterns import wheel_file_re from poetry.utils.patterns import wheel_file_re
......
...@@ -4,13 +4,13 @@ import urllib.parse ...@@ -4,13 +4,13 @@ import urllib.parse
import warnings import warnings
from collections import defaultdict from collections import defaultdict
from functools import cached_property
from html import unescape from html import unescape
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from poetry.core.packages.utils.link import Link from poetry.core.packages.utils.link import Link
from poetry.repositories.link_sources.base import LinkSource from poetry.repositories.link_sources.base import LinkSource
from poetry.utils._compat import cached_property
if TYPE_CHECKING: if TYPE_CHECKING:
......
from __future__ import annotations from __future__ import annotations
from collections import defaultdict from collections import defaultdict
from functools import cached_property
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import Any from typing import Any
from poetry.core.packages.utils.link import Link from poetry.core.packages.utils.link import Link
from poetry.repositories.link_sources.base import LinkSource from poetry.repositories.link_sources.base import LinkSource
from poetry.utils._compat import cached_property
if TYPE_CHECKING: if TYPE_CHECKING:
......
...@@ -21,12 +21,6 @@ if sys.version_info < (3, 10): ...@@ -21,12 +21,6 @@ if sys.version_info < (3, 10):
else: else:
from importlib import metadata from importlib import metadata
if sys.version_info < (3, 8):
# compatibility for python <3.8
from backports.cached_property import cached_property
else:
from functools import cached_property
WINDOWS = sys.platform == "win32" WINDOWS = sys.platform == "win32"
...@@ -58,7 +52,6 @@ def encode(string: str, encodings: list[str] | None = None) -> bytes: ...@@ -58,7 +52,6 @@ def encode(string: str, encodings: list[str] | None = None) -> bytes:
__all__ = [ __all__ = [
"WINDOWS", "WINDOWS",
"cached_property",
"decode", "decode",
"encode", "encode",
"metadata", "metadata",
......
...@@ -338,10 +338,7 @@ class SitePackages: ...@@ -338,10 +338,7 @@ class SitePackages:
files = [] if distribution.files is None else distribution.files files = [] if distribution.files is None else distribution.files
for file in files: for file in files:
path = Path(distribution.locate_file(file)) path = Path(distribution.locate_file(file))
path.unlink(missing_ok=True)
# We can't use unlink(missing_ok=True) because it's not always available
if path.exists():
path.unlink()
distribution_path: Path = distribution._path # type: ignore[attr-defined] distribution_path: Path = distribution._path # type: ignore[attr-defined]
if distribution_path.exists(): if distribution_path.exists():
...@@ -544,7 +541,7 @@ class EnvManager: ...@@ -544,7 +541,7 @@ class EnvManager:
if executable: if executable:
python_patch = decode( python_patch = decode(
subprocess.check_output( subprocess.check_output(
[str(executable), "-c", GET_PYTHON_VERSION_ONELINER], [executable, "-c", GET_PYTHON_VERSION_ONELINER],
).strip() ).strip()
) )
...@@ -579,7 +576,7 @@ class EnvManager: ...@@ -579,7 +576,7 @@ class EnvManager:
try: try:
python_version_string = decode( python_version_string = decode(
subprocess.check_output( subprocess.check_output(
[str(python_path), "-c", GET_PYTHON_VERSION_ONELINER], [python_path, "-c", GET_PYTHON_VERSION_ONELINER],
) )
) )
except CalledProcessError as e: except CalledProcessError as e:
...@@ -906,7 +903,7 @@ class EnvManager: ...@@ -906,7 +903,7 @@ class EnvManager:
if executable: if executable:
python_patch = decode( python_patch = decode(
subprocess.check_output( subprocess.check_output(
[str(executable), "-c", GET_PYTHON_VERSION_ONELINER], [executable, "-c", GET_PYTHON_VERSION_ONELINER],
).strip() ).strip()
) )
python_minor = ".".join(python_patch.split(".")[:2]) python_minor = ".".join(python_patch.split(".")[:2])
...@@ -954,7 +951,7 @@ class EnvManager: ...@@ -954,7 +951,7 @@ class EnvManager:
try: try:
python_patch = decode( python_patch = decode(
subprocess.check_output( subprocess.check_output(
[str(python), "-c", GET_PYTHON_VERSION_ONELINER], [python, "-c", GET_PYTHON_VERSION_ONELINER],
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
).strip() ).strip()
) )
......
from __future__ import annotations
import sys
if sys.version_info < (3, 8):
import zipp as zipfile # nopycln: import
from typing_extensions import Protocol # nopycln: import
else:
import zipfile
from typing import Protocol
__all__ = ["zipfile", "Protocol"]
...@@ -2,6 +2,7 @@ from __future__ import annotations ...@@ -2,6 +2,7 @@ from __future__ import annotations
from pathlib import Path from pathlib import Path
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import Protocol
import pytest import pytest
...@@ -14,7 +15,6 @@ from poetry.plugins import ApplicationPlugin ...@@ -14,7 +15,6 @@ from poetry.plugins import ApplicationPlugin
from poetry.plugins import Plugin from poetry.plugins import Plugin
from poetry.plugins.plugin_manager import PluginManager from poetry.plugins.plugin_manager import PluginManager
from poetry.poetry import Poetry from poetry.poetry import Poetry
from tests.compat import Protocol
from tests.helpers import mock_metadata_entry_points from tests.helpers import mock_metadata_entry_points
......
from __future__ import annotations from __future__ import annotations
import zipfile
from pathlib import Path from pathlib import Path
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import NamedTuple from typing import NamedTuple
...@@ -9,7 +11,6 @@ import pytest ...@@ -9,7 +11,6 @@ import pytest
from poetry.repositories.installed_repository import InstalledRepository from poetry.repositories.installed_repository import InstalledRepository
from poetry.utils._compat import metadata from poetry.utils._compat import metadata
from poetry.utils.env import MockEnv as BaseMockEnv from poetry.utils.env import MockEnv as BaseMockEnv
from tests.compat import zipfile
if TYPE_CHECKING: if TYPE_CHECKING:
......
...@@ -2,8 +2,7 @@ from __future__ import annotations ...@@ -2,8 +2,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import Any from typing import Any
from typing import Protocol
from tests.compat import Protocol
if TYPE_CHECKING: if TYPE_CHECKING:
......
...@@ -192,7 +192,6 @@ def check_output_wrapper( ...@@ -192,7 +192,6 @@ def check_output_wrapper(
) -> Callable[[list[str], Any, Any], str]: ) -> Callable[[list[str], Any, Any], str]:
def check_output(cmd: list[str], *args: Any, **kwargs: Any) -> str: def check_output(cmd: list[str], *args: Any, **kwargs: Any) -> str:
# cmd is a list, like ["python", "-c", "do stuff"] # cmd is a list, like ["python", "-c", "do stuff"]
assert all(isinstance(arg, str) for arg in cmd)
python_cmd = cmd[2] python_cmd = cmd[2]
if "sys.version_info[:3]" in python_cmd: if "sys.version_info[:3]" in python_cmd:
return version.text return version.text
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment