Skip to content
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

More type fixes #361

Merged
merged 3 commits into from
May 22, 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
29 changes: 28 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ tox = "^3.0"
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
Expand Down Expand Up @@ -84,9 +86,7 @@ exclude = "(?x)(^tests/.*/fixtures | ^src/poetry/core/_vendor)"

[[tool.mypy.overrides]]
module = [
'jsonschema.*',
'lark.*',
'setuptools.*',
'tomlkit.*',
'virtualenv.*',
]
Expand Down
6 changes: 3 additions & 3 deletions src/poetry/core/json/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/poetry/core/packages/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 1 addition & 4 deletions tests/fixtures/project_with_setup/setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup


kwargs = dict(
setup(
name="my-package",
license="MIT",
version="0.1.2",
Expand All @@ -12,6 +12,3 @@
packages=["my_package"],
install_requires=["pendulum>=1.4.4", "cachy[msgpack]>=0.2.0"],
)


setup(**kwargs)