-
Notifications
You must be signed in to change notification settings - Fork 244
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
Address TODO in pyproject/tables #600
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
from __future__ import annotations | ||
|
||
from contextlib import suppress | ||
from dataclasses import dataclass | ||
from dataclasses import field | ||
from pathlib import Path | ||
from typing import TYPE_CHECKING | ||
|
||
|
@@ -9,18 +10,15 @@ | |
from poetry.core.packages.dependency import Dependency | ||
|
||
|
||
# TODO: Convert to dataclass once python 2.7, 3.5 is dropped | ||
@dataclass | ||
class BuildSystem: | ||
def __init__( | ||
self, build_backend: str | None = None, requires: list[str] | None = None | ||
) -> None: | ||
self.build_backend = ( | ||
build_backend | ||
if build_backend is not None | ||
else "setuptools.build_meta:__legacy__" | ||
) | ||
self.requires = requires if requires is not None else ["setuptools", "wheel"] | ||
self._dependencies: list[Dependency] | None = None | ||
build_backend: str | None = field(default=None) | ||
requires: list[str] = field(default_factory=list) | ||
_dependencies: list[Dependency] | None = field(default=None, init=False) | ||
|
||
def __post_init__(self) -> None: | ||
self.build_backend = self.build_backend or "setuptools.build_meta:__legacy__" | ||
self.requires = self.requires or ["setuptools", "wheel"] | ||
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. According to the old implementation By the way, we should probably require |
||
|
||
@property | ||
def dependencies(self) -> list[Dependency]: | ||
|
@@ -38,13 +36,10 @@ def dependencies(self) -> list[Dependency]: | |
except ValueError: | ||
# PEP 517 requires can be path if not PEP 508 | ||
path = Path(requirement) | ||
# compatibility Python < 3.8 | ||
# https://docs.python.org/3/library/pathlib.html#methods | ||
with suppress(OSError): | ||
if path.is_file(): | ||
dependency = FileDependency(name=path.name, path=path) | ||
elif path.is_dir(): | ||
dependency = DirectoryDependency(name=path.name, path=path) | ||
if path.is_file(): | ||
dependency = FileDependency(name=path.name, path=path) | ||
elif path.is_dir(): | ||
dependency = DirectoryDependency(name=path.name, path=path) | ||
|
||
if dependency is None: | ||
# skip since we could not determine requirement | ||
|
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.
As it is now, I think it's a step backwards compared to the old implementation.
build_backend
should be of typestr
even ifNone
can be passed to__init__
. IMO, we should find a better solution with dataclasses or keep the old implementation and just remove the TODO.