This repository has been archived by the owner on Dec 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from MousaZeidBaker/refactor/structure
Refactor project structure and classes
- Loading branch information
Showing
21 changed files
with
277 additions
and
812 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from dataclasses import dataclass | ||
from typing import Dict, List, Union | ||
|
||
|
||
@dataclass(frozen=True) | ||
class Dependency: | ||
"""A class to represent a dependency | ||
Args: | ||
name: The name of the dependency | ||
version: The version of the dependency | ||
group: The group of the dependency | ||
""" | ||
|
||
name: str | ||
version: Union[str, Dict, List] | ||
group: str | ||
|
||
@property | ||
def normalized_name(self) -> str: | ||
# https://www.python.org/dev/peps/pep-0503/#normalized-names | ||
return self.name.replace("_", "-").lower() | ||
|
||
@property | ||
def constraint(self) -> str: | ||
if isinstance(self.version, str): | ||
if self.version[0].startswith(("^", "~")): | ||
return self.version[0] | ||
elif isinstance(self.version, Dict): | ||
if self.version.get("version", "").startswith(("^", "~")): | ||
return self.version["version"][0] | ||
return "" # dependencies with exact version or multiple versions |
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
32 changes: 0 additions & 32 deletions
32
tests/unit/fixtures/expected_pyproject/pyproject_with_capital_letters.toml
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
tests/unit/fixtures/expected_pyproject/pyproject_with_dependency_groups.toml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.