-
Notifications
You must be signed in to change notification settings - Fork 252
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
typechecking poetry.core.masonry #274
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4f88be8
typechecking poetry.core.masonry
dimbleby 15d2419
reinstate ignore_packages_formats
dimbleby 7778af2
shuffling the Builder methods
dimbleby 58d0c1d
remove unnecessary __init__
dimbleby f6258d7
introduce default_target_dir on builders
dimbleby File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,14 +33,14 @@ def __init__( | |
self, | ||
poetry: Poetry, | ||
ignore_packages_formats: bool = False, | ||
executable: Path | str | None = None, | ||
executable: Path | None = None, | ||
) -> None: | ||
from poetry.core.masonry.metadata import Metadata | ||
from poetry.core.masonry.utils.module import Module | ||
|
||
self._poetry = poetry | ||
self._package = poetry.package | ||
self._path = poetry.file.parent | ||
self._path: Path = poetry.file.parent | ||
self._excluded_files: set[str] | None = None | ||
self._executable = Path(executable or sys.executable) | ||
|
||
|
@@ -93,7 +93,11 @@ def __init__( | |
def executable(self) -> Path: | ||
return self._executable | ||
|
||
def build(self) -> None: | ||
@property | ||
def default_target_dir(self) -> Path: | ||
return self._path / "dist" | ||
|
||
def build(self, target_dir: Path | None) -> Path: | ||
raise NotImplementedError() | ||
|
||
def find_excluded_files(self, fmt: str | None = None) -> set[str]: | ||
|
@@ -203,10 +207,6 @@ def find_files_to_add(self, exclude_build: bool = True) -> set[BuildIncludeFile] | |
if file.suffix == ".pyc": | ||
continue | ||
|
||
if file in to_add: | ||
# Skip duplicates | ||
continue | ||
|
||
logger.debug(f"Adding: {str(file)}") | ||
to_add.add(include_file) | ||
|
||
|
@@ -349,6 +349,8 @@ def convert_script_files(self) -> list[Path]: | |
@classmethod | ||
def convert_author(cls, author: str) -> dict[str, str]: | ||
m = AUTHOR_REGEX.match(author) | ||
if m is None: | ||
raise RuntimeError(f"{author} does not match regex") | ||
|
||
name = m.group("name") | ||
email = m.group("email") | ||
|
@@ -378,14 +380,11 @@ def __init__( | |
|
||
self.path = self.path.resolve() | ||
|
||
def __eq__(self, other: BuildIncludeFile | Path) -> bool: | ||
if hasattr(other, "path"): | ||
return self.path == other.path | ||
|
||
return self.path == other | ||
def __eq__(self, other: object) -> bool: | ||
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. Why are we disallowing comparison with Path? 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. Not disallowing, but always returning False. Because a BuildIncludeFile is not a Path! |
||
if not isinstance(other, BuildIncludeFile): | ||
abn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return False | ||
|
||
def __ne__(self, other: BuildIncludeFile | Path) -> bool: | ||
return not self.__eq__(other) | ||
return self.path == other.path | ||
|
||
def __hash__(self) -> int: | ||
return hash(self.path) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
to_add
is a set, it couldn't contain duplicates if it tried. Just need to be happy with__hash__
and__eq__
on theBuildIncludeFile
.