From 460cfa5f6f0e62af41e0937901cbda527888701c Mon Sep 17 00:00:00 2001 From: David Hotham Date: Sat, 21 May 2022 16:36:39 +0100 Subject: [PATCH 1/3] a couple of type generics missed last time --- src/poetry/core/packages/package.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/poetry/core/packages/package.py b/src/poetry/core/packages/package.py index 3b3bfda41..d96981fb2 100644 --- a/src/poetry/core/packages/package.py +++ b/src/poetry/core/packages/package.py @@ -526,14 +526,14 @@ def with_python_versions(self, python_versions: str) -> Iterator[None]: self.python_versions = original_python_versions - def with_features(self, features: Iterable[str]) -> Package: + def with_features(self: T, features: Iterable[str]) -> T: package = self.clone() package._features = frozenset(features) return package - def without_features(self) -> Package: + def without_features(self: T) -> T: return self.with_features([]) def clone(self: T) -> T: From 2438aded0865794ea028ba0b9ac13618ac5a0fd2 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Sat, 21 May 2022 16:38:49 +0100 Subject: [PATCH 2/3] use types-jsonschema --- poetry.lock | 17 ++++++++++++++++- pyproject.toml | 2 +- src/poetry/core/json/__init__.py | 6 +++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/poetry.lock b/poetry.lock index 4af580964..e1019cd40 100644 --- a/poetry.lock +++ b/poetry.lock @@ -78,6 +78,7 @@ python-versions = ">=3.7" [package.dependencies] colorama = {version = "*", markers = "platform_system == \"Windows\""} +importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} [[package]] name = "colorama" @@ -201,8 +202,10 @@ python-versions = ">=3.7" [package.dependencies] attrs = ">=17.4.0" +importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} importlib-resources = {version = ">=1.4.0", 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" +typing-extensions = {version = "*", markers = "python_version < \"3.8\""} [package.extras] format = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-validator", "rfc3987", "uri-template", "webcolors (>=1.11)"] @@ -494,6 +497,14 @@ category = "dev" optional = false python-versions = ">=3.6" +[[package]] +name = "types-jsonschema" +version = "4.4.4" +description = "Typing stubs for jsonschema" +category = "dev" +optional = false +python-versions = "*" + [[package]] name = "typing-extensions" version = "4.2.0" @@ -569,7 +580,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest- [metadata] lock-version = "1.1" python-versions = "^3.7" -content-hash = "6a30ae707fbf9c55c55d5cee780d581369ee1cd21d0b5e73461e1a718b33e259" +content-hash = "20e46388c357808e7a6a077b363e47375ac10c8183b2fb2c75b4a8609296759a" [metadata.files] atomicwrites = [ @@ -868,6 +879,10 @@ typed-ast = [ {file = "typed_ast-1.5.3-cp39-cp39-win_amd64.whl", hash = "sha256:20d5118e494478ef2d3a2702d964dae830aedd7b4d3b626d003eea526be18718"}, {file = "typed_ast-1.5.3.tar.gz", hash = "sha256:27f25232e2dd0edfe1f019d6bfaaf11e86e657d9bdb7b0956db95f560cceb2b3"}, ] +types-jsonschema = [ + {file = "types-jsonschema-4.4.4.tar.gz", hash = "sha256:d03f0c1a97ff06dda9535dfa51916a98f38bf40d6828ef4d93bc40708effe507"}, + {file = "types_jsonschema-4.4.4-py3-none-any.whl", hash = "sha256:294d2de9ea3564fbec6c56153e84d1f3f7d9b2ada36e183d88a63c126da7bc3d"}, +] typing-extensions = [ {file = "typing_extensions-4.2.0-py3-none-any.whl", hash = "sha256:6657594ee297170d19f67d55c05852a874e7eb634f4f753dbd667855e07c1708"}, {file = "typing_extensions-4.2.0.tar.gz", hash = "sha256:f1c24655a0da0d1b67f07e17a5e6b2a105894e6824b92096378bb3668ef02376"}, diff --git a/pyproject.toml b/pyproject.toml index e82912989..16b608adb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,6 +51,7 @@ tox = "^3.0" vendoring = {version = "^1.0", python = "^3.8"} build = "^0.7.0" mypy = ">=0.950" +types-jsonschema = ">=4.4.4" [tool.black] line-length = 88 @@ -84,7 +85,6 @@ exclude = "(?x)(^tests/.*/fixtures | ^src/poetry/core/_vendor)" [[tool.mypy.overrides]] module = [ - 'jsonschema.*', 'lark.*', 'setuptools.*', 'tomlkit.*', diff --git a/src/poetry/core/json/__init__.py b/src/poetry/core/json/__init__.py index 36adc4551..4402ca591 100644 --- a/src/poetry/core/json/__init__.py +++ b/src/poetry/core/json/__init__.py @@ -15,12 +15,12 @@ class ValidationError(ValueError): def validate_object(obj: dict[str, Any], schema_name: str) -> list[str]: - schema = os.path.join(SCHEMA_DIR, f"{schema_name}.json") + schema_file = os.path.join(SCHEMA_DIR, f"{schema_name}.json") - if not os.path.exists(schema): + if not os.path.exists(schema_file): raise ValueError(f"Schema {schema_name} does not exist.") - with open(schema, encoding="utf-8") as f: + with open(schema_file, encoding="utf-8") as f: schema = json.loads(f.read()) from jsonschema import Draft7Validator From b8c346f9507dbd3477b94d745b95f3c4547518bc Mon Sep 17 00:00:00 2001 From: David Hotham Date: Sat, 21 May 2022 16:42:48 +0100 Subject: [PATCH 3/3] use types-setuptools --- poetry.lock | 14 +++++++++++++- pyproject.toml | 2 +- tests/fixtures/project_with_setup/setup.py | 5 +---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/poetry.lock b/poetry.lock index e1019cd40..a7b7bcf54 100644 --- a/poetry.lock +++ b/poetry.lock @@ -505,6 +505,14 @@ category = "dev" optional = false python-versions = "*" +[[package]] +name = "types-setuptools" +version = "57.4.14" +description = "Typing stubs for setuptools" +category = "dev" +optional = false +python-versions = "*" + [[package]] name = "typing-extensions" version = "4.2.0" @@ -580,7 +588,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest- [metadata] lock-version = "1.1" python-versions = "^3.7" -content-hash = "20e46388c357808e7a6a077b363e47375ac10c8183b2fb2c75b4a8609296759a" +content-hash = "7b56fd3f95ff65af24a86bbadda3d16ba6f875828f5d999c68b92f770235150d" [metadata.files] atomicwrites = [ @@ -883,6 +891,10 @@ types-jsonschema = [ {file = "types-jsonschema-4.4.4.tar.gz", hash = "sha256:d03f0c1a97ff06dda9535dfa51916a98f38bf40d6828ef4d93bc40708effe507"}, {file = "types_jsonschema-4.4.4-py3-none-any.whl", hash = "sha256:294d2de9ea3564fbec6c56153e84d1f3f7d9b2ada36e183d88a63c126da7bc3d"}, ] +types-setuptools = [ + {file = "types-setuptools-57.4.14.tar.gz", hash = "sha256:df02fe1dd244f58cf4e67cfc3d0a97930a2d61a72dd89f21d81c71017cd83f9a"}, + {file = "types_setuptools-57.4.14-py3-none-any.whl", hash = "sha256:828f7e7e51e157876f47c80518b23ba0c3c36aa8081efd39d5d39f393938aec9"}, +] typing-extensions = [ {file = "typing_extensions-4.2.0-py3-none-any.whl", hash = "sha256:6657594ee297170d19f67d55c05852a874e7eb634f4f753dbd667855e07c1708"}, {file = "typing_extensions-4.2.0.tar.gz", hash = "sha256:f1c24655a0da0d1b67f07e17a5e6b2a105894e6824b92096378bb3668ef02376"}, diff --git a/pyproject.toml b/pyproject.toml index 16b608adb..a65e9b5d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,6 +52,7 @@ vendoring = {version = "^1.0", python = "^3.8"} build = "^0.7.0" mypy = ">=0.950" types-jsonschema = ">=4.4.4" +types-setuptools = ">=57.4.14" [tool.black] line-length = 88 @@ -86,7 +87,6 @@ exclude = "(?x)(^tests/.*/fixtures | ^src/poetry/core/_vendor)" [[tool.mypy.overrides]] module = [ 'lark.*', - 'setuptools.*', 'tomlkit.*', 'virtualenv.*', ] diff --git a/tests/fixtures/project_with_setup/setup.py b/tests/fixtures/project_with_setup/setup.py index 03c5a5396..ce86fe3d1 100644 --- a/tests/fixtures/project_with_setup/setup.py +++ b/tests/fixtures/project_with_setup/setup.py @@ -1,7 +1,7 @@ from setuptools import setup -kwargs = dict( +setup( name="my-package", license="MIT", version="0.1.2", @@ -12,6 +12,3 @@ packages=["my_package"], install_requires=["pendulum>=1.4.4", "cachy[msgpack]>=0.2.0"], ) - - -setup(**kwargs)