Skip to content

Commit

Permalink
Removed dependency on typing_extensions & hid uses behind `if TYPE_CH…
Browse files Browse the repository at this point in the history
…ECKING` guards
  • Loading branch information
dylan-robins committed Mar 31, 2024
1 parent a770636 commit c47aad1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion poetry.lock

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

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ include = [

[tool.poetry.dependencies]
python = "^3.8"
typing-extensions = "^4.10.0"

[tool.poetry.group.dev.dependencies]
pre-commit = ">=2.15.0"
Expand Down
18 changes: 12 additions & 6 deletions src/poetry/core/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@
from typing import Any
from typing import List
from typing import Union
from typing import cast

from packaging.utils import canonicalize_name

from poetry.core.packages.project_package import BuildConfigSpec
from poetry.core.packages.project_package import IncludeSpec
from poetry.core.utils.helpers import combine_unicode
from poetry.core.utils.helpers import readme_content_type


if TYPE_CHECKING:
from typing import cast

from packaging.utils import NormalizedName

from poetry.core.packages.dependency import Dependency
from poetry.core.packages.dependency_group import DependencyGroup
from poetry.core.packages.project_package import BuildConfigSpec
from poetry.core.packages.project_package import IncludeSpec
from poetry.core.packages.project_package import ProjectPackage
from poetry.core.poetry import Poetry
from poetry.core.spdx.license import License
Expand Down Expand Up @@ -200,9 +201,13 @@ def configure_package(

if "build" in config:
build = config["build"]
if not build:
build = {}
if not isinstance(build, dict):
build = {"script": build}
package.build_config = cast(BuildConfigSpec, build) or {}
if TYPE_CHECKING:
cast(BuildConfigSpec, build)
package.build_config = build

if "include" in config:
package.include = []
Expand All @@ -215,8 +220,9 @@ def configure_package(
if formats and not isinstance(formats, list):
formats = [formats]
include["format"] = formats

package.include.append(cast(IncludeSpec, include))
if TYPE_CHECKING:
include = cast(IncludeSpec, include)
package.include.append(include)

if "exclude" in config:
package.exclude = config["exclude"]
Expand Down
37 changes: 16 additions & 21 deletions src/poetry/core/packages/project_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,33 @@
from typing import Sequence
from typing import TypedDict

from typing_extensions import NotRequired

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]},
)

SupportedPackageFormats = Literal["sdist", "wheel"]

class PackageSpec(TypedDict):
include: str
to: str
format: list[SupportedPackageFormats]
BuildConfigSpec = TypedDict(
"BuildConfigSpec",
{"script": NotRequired[str], "generate-setup-file": NotRequired[bool]},
)

class PackageSpec(TypedDict):
include: str
to: str
format: list[SupportedPackageFormats]

class IncludeSpec(TypedDict):
path: str
format: list[SupportedPackageFormats]
class IncludeSpec(TypedDict):
path: str
format: list[SupportedPackageFormats]


class ProjectPackage(Package):
Expand Down

0 comments on commit c47aad1

Please sign in to comment.