-
Notifications
You must be signed in to change notification settings - Fork 251
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
Migrate anonymous Mapping[str, Any] to TypedDicts where their content is fully defined. #716
base: main
Are you sure you want to change the base?
Changes from all commits
4164e3f
ab19f9b
8595417
7337389
0d2f762
2abbd3c
a770636
c47aad1
f1319a7
451c811
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,7 @@ def _module(self) -> Module: | |
formats = [formats] | ||
|
||
if ( | ||
formats | ||
len(formats) > 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does that make a difference? Isn't the former more Pythonic? |
||
and self.format | ||
and self.format not in formats | ||
and not self._ignore_packages_formats | ||
|
@@ -80,7 +80,7 @@ def _module(self) -> Module: | |
formats = include.get("format", []) | ||
|
||
if ( | ||
formats | ||
len(formats) > 0 | ||
and self.format | ||
and self.format not in formats | ||
and not self._ignore_packages_formats | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,20 +3,38 @@ | |
import warnings | ||
|
||
from typing import TYPE_CHECKING | ||
from typing import Any | ||
from typing import Literal | ||
from typing import Mapping | ||
from typing import Sequence | ||
from typing import TypedDict | ||
|
||
from poetry.core.constraints.version import parse_constraint | ||
from poetry.core.packages.package import Package | ||
from poetry.core.packages.utils.utils import create_nested_marker | ||
from poetry.core.version.markers import parse_marker | ||
|
||
|
||
if TYPE_CHECKING: | ||
from typing_extensions import NotRequired | ||
|
||
from poetry.core.constraints.version import Version | ||
from poetry.core.packages.dependency import Dependency | ||
|
||
from poetry.core.packages.package import Package | ||
from poetry.core.packages.utils.utils import create_nested_marker | ||
SupportedPackageFormats = Literal["sdist", "wheel"] | ||
|
||
BuildConfigSpec = TypedDict( | ||
"BuildConfigSpec", | ||
{"script": NotRequired[str], "generate-setup-file": NotRequired[bool]}, | ||
) | ||
|
||
class PackageSpec(TypedDict): | ||
include: str | ||
to: str | ||
format: list[SupportedPackageFormats] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should probably be a |
||
|
||
class IncludeSpec(TypedDict): | ||
path: str | ||
format: list[SupportedPackageFormats] | ||
Comment on lines
+25
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since these were There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should probably be a |
||
|
||
|
||
class ProjectPackage(Package): | ||
|
@@ -39,10 +57,10 @@ def __init__( | |
# Attributes must be immutable for clone() to be safe! | ||
# (For performance reasons, clone only creates a copy instead of a deep copy). | ||
|
||
self.build_config: Mapping[str, Any] = {} | ||
self.packages: Sequence[Mapping[str, Any]] = [] | ||
self.include: Sequence[Mapping[str, Any]] = [] | ||
self.exclude: Sequence[Mapping[str, Any]] = [] | ||
self.build_config: BuildConfigSpec = {} | ||
self.packages: Sequence[PackageSpec] = [] | ||
self.include: Sequence[IncludeSpec] = [] | ||
self.exclude: Sequence[IncludeSpec] = [] | ||
self.custom_urls: Mapping[str, str] = {} | ||
|
||
if self._python_versions == "*": | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?