Skip to content

Commit

Permalink
Update mypy to 1.11
Browse files Browse the repository at this point in the history
Fix typing errors
  • Loading branch information
enpaul committed Aug 20, 2024
1 parent 863f88d commit 4b38b00
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 41 deletions.
81 changes: 45 additions & 36 deletions poetry.lock

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

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ ipython = {version = "^8.10.1", python = "^3.10"}
isort = {version = "^5.13.2", python = "^3.10"}
mdformat = {version = "^0.7", python = "^3.10"}
mdformat-gfm = {version = "^0.3", python = "^3.10"}
mypy = {version = "^0.930", python = "^3.10"}
mypy = {version = "^1.11.1", python = "^3.10"}
pre-commit = {version = "^3.8.0", python = "^3.10"}
pre-commit-hooks = {version = "^4.6.0", python = "^3.10"}
pylint = {version = "^3.2.6", python = "^3.10"}
Expand Down
19 changes: 15 additions & 4 deletions tox_poetry_installer/hooks/_tox_on_install_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from typing import Sequence
from typing import Set

from packaging.utils import NormalizedName
from poetry.core.packages.dependency import Dependency as PoetryDependency
from poetry.core.packages.package import Package as PoetryPackage
from tox.tox_env.api import ToxEnv as ToxVirtualEnv
Expand Down Expand Up @@ -154,7 +155,9 @@ def find_project_deps(
for extra in extras:
logger.info(f"Processing project extra '{extra}'")
try:
extra_dep_names += [item.name for item in poetry.package.extras[extra]]
extra_dep_names += [
item.name for item in poetry.package.extras[NormalizedName(extra)]
]
except KeyError:
raise exceptions.ExtraNotFoundError(
f"Environment specifies project extra '{extra}' which was not found in the lockfile"
Expand Down Expand Up @@ -213,7 +216,11 @@ def find_group_deps(
packages,
venv,
poetry,
poetry.pyproject.data["tool"]["poetry"]
# the type ignore here is due to the difficulties around getting nested data
# from the inherrently unstructured toml structure (which necessarily is flexibly
# typed) but in a situation where there is a meta-structure applied to it (i.e. a
# pyproject.toml structure).
poetry.pyproject.data["tool"]["poetry"] # type: ignore
.get("group", {})
.get(group, {})
.get("dependencies", {})
Expand All @@ -239,7 +246,11 @@ def find_dev_deps(
packages,
venv,
poetry,
poetry.pyproject.data["tool"]["poetry"].get("dev-dependencies", {}).keys(),
# the type ignore here is due to the difficulties around getting nested data
# from the inherrently unstructured toml structure (which necessarily is flexibly
# typed) but in a situation where there is a meta-structure applied to it (i.e. a
# pyproject.toml structure).
poetry.pyproject.data["tool"]["poetry"].get("dev-dependencies", {}).keys(), # type: ignore
)

# Poetry 1.2 unions these two toml sections.
Expand Down Expand Up @@ -345,6 +356,6 @@ def build_package_map(poetry: "_poetry.Poetry") -> PackageMap:
"""
packages = collections.defaultdict(list)
for package in poetry.locker.locked_repository().packages:
packages[package.name].append(package)
packages[str(package.name)].append(package)

return packages

0 comments on commit 4b38b00

Please sign in to comment.