From 72666312ae8bcd4372b6e8d24d8718baa65d4a0a Mon Sep 17 00:00:00 2001 From: Nathan Michlo Date: Fri, 26 Sep 2025 12:33:28 +0200 Subject: [PATCH 1/9] update .gitignore --- .gitignore | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 33bbec9..d535ddf 100644 --- a/.gitignore +++ b/.gitignore @@ -102,6 +102,8 @@ celerybeat.pid *.sage.py # Environments +.*.env +.env.* .env .venv env/ @@ -128,5 +130,9 @@ dmypy.json # Pyre type checker .pyre/ -# macos +## CUSTOM ## + .DS_Store +.idea/ +CLAUDE.local.md +.claude/settings.local.json From 8c7d4a948e537e731478df29036f4c3fbb81f179 Mon Sep 17 00:00:00 2001 From: Nathan Michlo Date: Fri, 26 Sep 2025 12:33:40 +0200 Subject: [PATCH 2/9] update .pre-commit config to use ruff and uv --- .pre-commit-config.yaml | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4c6ad5a..80ee2c2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,12 +1,19 @@ +fail_fast: false repos: + - repo: https://github.com/astral-sh/uv-pre-commit + rev: 0.8.19 + hooks: + - id: uv-lock + - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v6.0.0 hooks: - id: check-added-large-files args: ["--maxkb=500"] - id: check-case-conflict - id: detect-private-key + - id: check-merge-conflict - repo: https://github.com/asottile/pyupgrade rev: v3.15.2 @@ -15,22 +22,9 @@ repos: args: - "--py38-plus" - - repo: https://github.com/PyCQA/isort - rev: 5.13.2 - hooks: - - id: isort - name: isort - args: ["--verbose", "--py=39", "--profile=black"] - - - repo: https://github.com/psf/black - rev: 24.4.0 - hooks: - - id: black - args: ["--verbose", "--target-version=py39"] - - # this repo - - repo: https://github.com/nmichlo/pydependence - rev: v0.5.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.13.2 hooks: - - id: pydependence - args: ["pyproject.toml"] + - id: ruff-check + args: [ --fix ] + - id: ruff-format From a5cea1cd69441eb35e31849261cc7ec14b5fee82 Mon Sep 17 00:00:00 2001 From: Nathan Michlo Date: Fri, 26 Sep 2025 12:36:41 +0200 Subject: [PATCH 3/9] run globally fix pre-commit issues --- .pre-commit-config.yaml | 1 + pydependence/_cli.py | 5 +---- pydependence/_core/module_imports_ast.py | 5 ++--- pydependence/_core/module_imports_loader.py | 1 - pydependence/_core/modules_resolver.py | 4 +--- pydependence/_core/modules_scope.py | 2 -- pydependence/_core/requirements_map.py | 7 ------- pydependence/_core/requirements_out.py | 10 ++++----- pydependence/_core/utils.py | 17 ++++++++------- tests/test_module_data.py | 23 ++++++++------------- 10 files changed, 29 insertions(+), 46 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 80ee2c2..883c5d3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,4 +27,5 @@ repos: hooks: - id: ruff-check args: [ --fix ] + exclude: ^tests/test-packages/ - id: ruff-format diff --git a/pydependence/_cli.py b/pydependence/_cli.py index 90443c6..3dd7ee3 100644 --- a/pydependence/_cli.py +++ b/pydependence/_cli.py @@ -78,7 +78,6 @@ class _ResolveRules(pydantic.BaseModel, extra="forbid"): - # If true, then vist all the lazy imports. Usually the lazy imports are removed from # the import graph and we don't traverse these edges. This on the other-hand allows # all these edges to be traversed. This is often useful if you want to create @@ -382,7 +381,7 @@ def resolve_generate_and_write_requirements( resolver_name=self.get_output_extras_name(), ) except NoConfiguredRequirementMappingError as e: - msg = f"\n | ".join(["", *str(e).split("\n")]) + msg = "\n | ".join(["", *str(e).split("\n")]) msg = f"[requirement-mapping-error] output: {self.get_output_extras_name()}{msg}" raise NoConfiguredRequirementMappingError(msg, e.imports) from e # 3. write requirements @@ -624,7 +623,6 @@ def _validate_import(cls, v): class _ScopeRules(pydantic.BaseModel, extra="forbid"): - # Specify how to handle modules that are unreachable, e.g. if there is no `__init__.py` # file in all the parents leading up to importing this module. If this is the case # then the module/package does not correctly follow python/PEP convention and is @@ -768,7 +766,6 @@ class UndefinedScopeError(ValueError): class LoadedScopes: - def __init__(self): self._scopes = {} diff --git a/pydependence/_core/module_imports_ast.py b/pydependence/_core/module_imports_ast.py index 88c7df1..61903e7 100644 --- a/pydependence/_core/module_imports_ast.py +++ b/pydependence/_core/module_imports_ast.py @@ -29,7 +29,7 @@ import warnings from collections import Counter, defaultdict from enum import Enum -from typing import DefaultDict, Dict, List, Literal, NamedTuple, Optional, Tuple +from typing import DefaultDict, Dict, List, Literal, Optional, Tuple from pydependence._core.module_data import ModuleMetadata from pydependence._core.utils import assert_valid_import_name, assert_valid_module_path @@ -231,7 +231,6 @@ def tagged_name_and_target(self) -> str: class _AstImportsCollector(ast.NodeVisitor): - def __init__(self, module_info: ModuleMetadata): self._module_info: ModuleMetadata = module_info self._imports: "DefaultDict[str, List[LocImportInfo]]" = defaultdict(list) @@ -387,7 +386,7 @@ def visit_Call(self, node: ast.Call): return # - make sure no keyword arguments are used, these invalidate the import. if node.keywords: - self._node_warn(node, f"should not have keyword arguments.") + self._node_warn(node, "should not have keyword arguments.") return # - make sure that the function is called with a single string argument if not len(node.args) == 1: diff --git a/pydependence/_core/module_imports_loader.py b/pydependence/_core/module_imports_loader.py index fc8a9d1..5d17aea 100644 --- a/pydependence/_core/module_imports_loader.py +++ b/pydependence/_core/module_imports_loader.py @@ -57,7 +57,6 @@ def from_module_info_and_parsed_file(cls, module_info: ModuleMetadata): class _ModuleImportsLoader: - def __init__(self): # TODO: tag could severally hurt performance? maybe should change data structure slightly? # problem is tag is nested and applied to imports too. HOWEVER, Usually tag is diff --git a/pydependence/_core/modules_resolver.py b/pydependence/_core/modules_resolver.py index f1bf471..7fcd30c 100644 --- a/pydependence/_core/modules_resolver.py +++ b/pydependence/_core/modules_resolver.py @@ -24,7 +24,7 @@ import warnings from collections import defaultdict -from typing import Dict, Iterable, List, NamedTuple, Optional, Set, Tuple +from typing import Dict, List, NamedTuple, Optional, Set, Tuple import networkx as nx @@ -178,7 +178,6 @@ def _resolve_scope_imports( class ScopeResolvedImports: - def __init__( self, scope: "ModulesScope", @@ -222,7 +221,6 @@ def get_filtered( exclude_in_search_space: bool = True, exclude_builtins: bool = True, ) -> "ScopeResolvedImports": - def _keep(imp: LocImportInfo) -> bool: if exclude_builtins and imp.target in BUILTIN_MODULE_NAMES: return False diff --git a/pydependence/_core/modules_scope.py b/pydependence/_core/modules_scope.py index b728141..e41aa24 100644 --- a/pydependence/_core/modules_scope.py +++ b/pydependence/_core/modules_scope.py @@ -26,7 +26,6 @@ from enum import Enum from pathlib import Path from typing import ( - TYPE_CHECKING, Dict, Iterable, Iterator, @@ -204,7 +203,6 @@ class RestrictOp(str, Enum): class ModulesScope: - def __init__(self): self._module_graph = nx.DiGraph() self.__import_graph_strict = None diff --git a/pydependence/_core/requirements_map.py b/pydependence/_core/requirements_map.py index 883f323..2fd2b90 100644 --- a/pydependence/_core/requirements_map.py +++ b/pydependence/_core/requirements_map.py @@ -30,7 +30,6 @@ from pydependence._core.builtin import BUILTIN_MODULE_NAMES from pydependence._core.module_imports_ast import ( BasicImportInfo, - LocImportInfo, ManualImportInfo, ) from pydependence._core.requirements_out import ( @@ -53,7 +52,6 @@ class ImportMatcherBase(abc.ABC): - @abc.abstractmethod def match(self, import_: str) -> bool: raise NotImplementedError @@ -64,7 +62,6 @@ def cfg_str(self) -> str: class ImportMatcherScope(ImportMatcherBase): - def __init__(self, scope: "ModulesScope"): self.scope = scope @@ -76,7 +73,6 @@ def cfg_str(self) -> str: class ImportMatcherGlob(ImportMatcherBase): - def __init__(self, import_glob: str): self._orig = import_glob (*parts, last) = import_glob.split(".") @@ -116,7 +112,6 @@ def cfg_str(self) -> str: class ImportMatcherGlobs(ImportMatcherBase): - def __init__(self, import_globs: "Union[str, List[str]]"): if isinstance(import_globs, str): import_globs = import_globs.split(",") @@ -218,7 +213,6 @@ def to_output_requirements(self): class NoConfiguredRequirementMappingError(ValueError): - def __init__(self, msg: str, imports: Set[str]): self.msg = msg self.imports = imports @@ -235,7 +229,6 @@ def cfg_str(self) -> str: class RequirementsMapper: - def __init__( self, *, diff --git a/pydependence/_core/requirements_out.py b/pydependence/_core/requirements_out.py index 38671fd..a3bee79 100644 --- a/pydependence/_core/requirements_out.py +++ b/pydependence/_core/requirements_out.py @@ -87,7 +87,7 @@ def get_source_info( return [ SrcInfo( name=src.source_module, - comment=f"[L]" if annotate and src.is_lazy else "", + comment="[L]" if annotate and src.is_lazy else "", ) for src in self.sources ] @@ -162,16 +162,16 @@ def as_requirements_txt( # add requirement lines.append(f"{req.requirement}") # add annotations - lines[ - -1 - ] += f"{req.get_annotations_string(enabled=sources_annotations, comment=True)}" + lines[-1] += ( + f"{req.get_annotations_string(enabled=sources_annotations, comment=True)}" + ) # add compact sources if sources: if sources_compact: lines[-1] += f" # {req.get_sources_string(roots=sources_roots)}" else: for src_info in req.get_source_info(roots=sources_roots): - lines.append(f"{' '*indent_size*1}# {src_info.anno_str}") + lines.append(f"{' ' * indent_size * 1}# {src_info.anno_str}") if self.requirements or notice: lines.append("") return "\n".join(lines) diff --git a/pydependence/_core/utils.py b/pydependence/_core/utils.py index e359ac4..c66b751 100644 --- a/pydependence/_core/utils.py +++ b/pydependence/_core/utils.py @@ -23,7 +23,10 @@ # ============================================================================== # from pathlib import Path -from typing import List, Union +from typing import List, TYPE_CHECKING, Union + +if TYPE_CHECKING: + import tomlkit # ========================================================================= # # AST IMPORT PARSER # @@ -99,9 +102,9 @@ def load_toml_document( raise FileNotFoundError(f"path is not a file: {path}") with open(path) as fp: toml = tomlkit.load(fp) - assert isinstance( - toml, tomlkit.toml_document.TOMLDocument - ), f"got {type(toml)}, not TOMLDocument" + assert isinstance(toml, tomlkit.toml_document.TOMLDocument), ( + f"got {type(toml)}, not TOMLDocument" + ) return toml @@ -135,9 +138,9 @@ def toml_file_replace_array( # TODO: this needs multiple loads and writes if we are modifying multiple arrays # which is not ideal... but it is a simple solution for now. - assert isinstance( - array, tomlkit.items.Array - ), f"array must be a tomlkit Array, got: {type(array)}" + assert isinstance(array, tomlkit.items.Array), ( + f"array must be a tomlkit Array, got: {type(array)}" + ) # load file file = Path(file) diff --git a/tests/test_module_data.py b/tests/test_module_data.py index 205220e..ec07d42 100644 --- a/tests/test_module_data.py +++ b/tests/test_module_data.py @@ -37,7 +37,6 @@ ) from pydependence._core.module_imports_loader import ( DEFAULT_MODULE_IMPORTS_LOADER, - ModuleImports, ) from pydependence._core.modules_resolver import ( ScopeNotASubsetError, @@ -53,8 +52,6 @@ _find_modules, ) from pydependence._core.requirements_map import ( - DEFAULT_REQUIREMENTS_ENV, - ImportMatcherBase, ImportMatcherGlob, ImportMatcherScope, NoConfiguredRequirementMappingError, @@ -257,7 +254,7 @@ def test_find_modules_search_path(module_info): ("B", "B.b2"), } # not included! - edges_unreachable = { + _edges_unreachable = { ("A.a4", "A.a4.a4i"), } @@ -413,7 +410,6 @@ def test_find_modules_pkg_path(): def test_modules_scope(): - modules_a = {"A", "A.a1", "A.a2", "A.a3", "A.a3.a3i", "A.a4.a4i"} modules_b = {"B", "B.b1", "B.b2"} modules_c = {"C"} @@ -875,7 +871,9 @@ def test_requirement_mapping(): ) # test - m = lambda x: mapper.map_import_to_requirement(x, requirements_env="default") + def m(x): + mapper.map_import_to_requirement(x, requirements_env="default") + # in order: assert m("A.a3.a3i") == "glob_Aa3" assert m("A.a4") == "glob_A" @@ -888,7 +886,9 @@ def test_requirement_mapping(): assert m("asdf.fdsa") == "asdf" # take root # test alt - m = lambda x: mapper.map_import_to_requirement(x, requirements_env="asdf") + def m(x): + mapper.map_import_to_requirement(x, requirements_env="asdf") + # in order: assert m("A.a3.a3i") == "ALT_glob_Aa3" assert m("A.a4") == "glob_A" @@ -1100,7 +1100,7 @@ def test_requirements_txt_gen(mapper: RequirementsMapper): sources_compact=True, sources_roots=True, indent_size=4, - ) == ("extern_D\nfoo\n" "glob_extern\n" "package\n") + ) == ("extern_D\nfoo\nglob_extern\npackage\n") assert mapped.as_requirements_txt( notice=True, @@ -1209,12 +1209,7 @@ def test_toml_array_gen(mapper: RequirementsMapper): sources_roots=True, indent_size=4, ).as_string() == ( - "[\n" - ' "extern_D",\n' - ' "foo",\n' - ' "glob_extern",\n' - ' "package",\n' - "]" + '[\n "extern_D",\n "foo",\n "glob_extern",\n "package",\n]' ) assert mapped.as_toml_array( From d2729ed5c4ebb3ffb99abb36ef501e4e52c14bef Mon Sep 17 00:00:00 2001 From: Nathan Michlo Date: Fri, 26 Sep 2025 12:43:08 +0200 Subject: [PATCH 4/9] revert lock re-add this repo --- .pre-commit-config.yaml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 883c5d3..12e4c7c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,10 @@ fail_fast: false repos: - - repo: https://github.com/astral-sh/uv-pre-commit - rev: 0.8.19 - hooks: - - id: uv-lock + # - repo: https://github.com/astral-sh/uv-pre-commit + # rev: 0.8.19 + # hooks: + # - id: uv-lock - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 @@ -29,3 +29,10 @@ repos: args: [ --fix ] exclude: ^tests/test-packages/ - id: ruff-format + + # this repo + - repo: https://github.com/nmichlo/pydependence + rev: v0.5.0 + hooks: + - id: pydependence + args: ["pyproject.toml"] From beffc7cecf5d2237d19afeb7c8939e001d60849b Mon Sep 17 00:00:00 2001 From: Nathan Michlo Date: Fri, 26 Sep 2025 15:32:08 +0200 Subject: [PATCH 5/9] upgrade python 3.13 --- .pre-commit-config.yaml | 4 +- .pre-commit-hooks.yaml | 2 +- pydependence/_cli.py | 58 ++++++++++++------------ pydependence/_core/module_data.py | 3 +- pydependence/_core/module_imports_ast.py | 4 +- pydependence/_core/modules_scope.py | 13 ++---- pydependence/_core/requirements_map.py | 22 ++++----- pydependence/_core/requirements_out.py | 8 ++-- pyproject.toml | 12 ----- 9 files changed, 56 insertions(+), 70 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 12e4c7c..2e15745 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,11 +16,11 @@ repos: - id: check-merge-conflict - repo: https://github.com/asottile/pyupgrade - rev: v3.15.2 + rev: v3.20.0 hooks: - id: pyupgrade args: - - "--py38-plus" + - "--py313-plus" - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.13.2 diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 465da06..02b7c9c 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -6,7 +6,7 @@ always_run: true verbose: true entry: python3 -m pydependence - language_version: "3.9" + language_version: "3.13" additional_dependencies: - 'pydantic==2.*' - 'packaging' diff --git a/pydependence/_cli.py b/pydependence/_cli.py index 3dd7ee3..bc5a666 100644 --- a/pydependence/_cli.py +++ b/pydependence/_cli.py @@ -30,11 +30,11 @@ from collections import defaultdict from enum import Enum from pathlib import Path -from typing import Dict, List, Literal, Optional, Union +from typing import Literal, Union import pydantic from packaging.requirements import Requirement -from typing_extensions import Annotated +from typing import Annotated from pydependence._core.module_imports_ast import ManualImportInfo from pydependence._core.modules_scope import ( @@ -85,7 +85,7 @@ class _ResolveRules(pydantic.BaseModel, extra="forbid"): # that you define should be optional. Also useful if you want to generate a minimal # dependencies list, and then in optional dependency lists you want to create a full # set of requirements for everything! - visit_lazy: Optional[bool] = None + visit_lazy: bool | None = None # only applicable when `visit_lazy=False`, then in this case we re-add the lazy # imports that are directly referenced in all the traversed files, i.e. it is a @@ -95,31 +95,31 @@ class _ResolveRules(pydantic.BaseModel, extra="forbid"): # within the same scope as this could cause missing imports, rather specify # `visit_lazy=True` in this case. # * [A.K.A.] `shallow_include_lazy=True` - re_add_lazy: Optional[bool] = None + re_add_lazy: bool | None = None # If true, then exclude imports that were not encountered as we traversed the import # graph. [NOTE]: this is probably useful if you don't want to include all imports # below a specific scope, but only want to resolve what is actually encountered. # Not entirely sure this has much of an effect? - exclude_unvisited: Optional[bool] = None + exclude_unvisited: bool | None = None # If true, then exclude all imports that are part of the current scope. This usually # should not have any effect because imports are replaced as we traverse the graph # through the current scope, [NOTE] thus not entirely sure that this has any effect, # should it be a bug if we encounter any of these? - exclude_in_search_space: Optional[bool] = None + exclude_in_search_space: bool | None = None # If true, then exclude all the python builtin package names from being output in # the requirements files. This usually should be true unless you are trying to debug # as this would generate invalid requirements list as these would not exist on pypi. - exclude_builtins: Optional[bool] = None + exclude_builtins: bool | None = None # Check that generated imports and requirements have entries in the versions list. # If strict mode is enabled, then an error is thrown if a version entry is missing. # If strict mode is disabled, then a warning should be given, and the root import # name is used instead of the requirement name, which may or may not match up # to an actual python package. - strict_requirements_map: Optional[bool] = None + strict_requirements_map: bool | None = None # TODO: we should add some sort of option to ensure that generated dependency lists # exactly match some pre-defined set, while also outputting this set. @@ -259,11 +259,11 @@ class OutputModeEnum(str, Enum): class _Output(_ResolveRules, extra="forbid"): # resolve - scope: Optional[str] = None - start_scope: Optional[str] = None + scope: str | None = None + start_scope: str | None = None # raw requirements / imports that are mapped - raw: Optional[List[str]] = None + raw: list[str] | None = None # requirements mapping env: str = DEFAULT_REQUIREMENTS_ENV @@ -273,7 +273,7 @@ class _Output(_ResolveRules, extra="forbid"): output_file: str # !!!NB!!! DO NOT USE DIRECTLY! INSTEAD, USE `get_output_extras_name` - output_name: Optional[str] = None + output_name: str | None = None def get_output_extras_name(self) -> str: if self.output_name is not None: @@ -438,7 +438,7 @@ def _write_requirements( class _OutputPyprojectOptionalDeps(_Output): output_mode: Literal[OutputModeEnum.optional_dependencies] - output_file: Optional[str] = None + output_file: str | None = None def _write_requirements( self, mapped_requirements: OutMappedRequirements, *, dry_run: bool @@ -466,7 +466,7 @@ def _write_requirements( class _OutputPyprojectDeps(_Output): output_mode: Literal[OutputModeEnum.dependencies] - output_file: Optional[str] = None + output_file: str | None = None def _write_requirements( self, mapped_requirements: OutMappedRequirements, *, dry_run: bool @@ -566,8 +566,8 @@ class CfgVersion(pydantic.BaseModel, extra="forbid", arbitrary_types_allowed=Tru # the pip install requirement requirement: str # the imports to replace - import_: Optional[List[str]] = pydantic.Field(default=None, alias="import") - scope: Optional[str] = None + import_: list[str] | None = pydantic.Field(default=None, alias="import") + scope: str | None = None # only apply this import to this environment env: str = DEFAULT_REQUIREMENTS_ENV @@ -628,7 +628,7 @@ class _ScopeRules(pydantic.BaseModel, extra="forbid"): # then the module/package does not correctly follow python/PEP convention and is # technically invalid. By default, for `error`, we raise an exception and do not allow # the scope to be created, but this can be relaxed to `skip` or `keep` these files. - unreachable_mode: Optional[UnreachableModeEnum] = None + unreachable_mode: UnreachableModeEnum | None = None @classmethod def make_default_base_rules(cls): @@ -648,12 +648,12 @@ class CfgScope(_ScopeRules, extra="forbid"): name: str # parents - parents: List[str] = pydantic.Field(default_factory=list) + parents: list[str] = pydantic.Field(default_factory=list) # search paths - search_paths: List[str] = pydantic.Field(default_factory=list) - pkg_paths: List[str] = pydantic.Field(default_factory=list) - unreachable_mode: Optional[UnreachableModeEnum] = None + search_paths: list[str] = pydantic.Field(default_factory=list) + pkg_paths: list[str] = pydantic.Field(default_factory=list) + unreachable_mode: UnreachableModeEnum | None = None # extra packages # packages: List[str] = pydantic.Field(default_factory=list) @@ -663,15 +663,15 @@ class CfgScope(_ScopeRules, extra="forbid"): # e.g. limit=foo.bar, exclude=foo.bar.baz, include=foo.bar.baz.qux # if order of include and exclude were swapped, then the exclude would # remove the module after the include added it back in - limit: Optional[List[str]] = None - exclude: Optional[List[str]] = None + limit: list[str] | None = None + exclude: list[str] | None = None # include: Optional[str] = None # NOT IMPLEMENTED BECAUSE IT IS REDUNDANT, AND `PARENTS` CAN BE USED INSTEAD # sub-scopes # - name to import path map # - names must be unique across all scopes & sub-scopes # - imports must belong to the scope - subscopes: Dict[str, str] = pydantic.Field(default_factory=dict) + subscopes: dict[str, str] = pydantic.Field(default_factory=dict) @pydantic.field_validator("search_paths", mode="before") @classmethod @@ -786,7 +786,7 @@ def __setitem__(self, key, value): self._scopes[key] = value @property - def sorted_names(self) -> List[str]: + def sorted_names(self) -> list[str]: return sorted(self._scopes.keys()) @@ -809,13 +809,13 @@ class PydependenceCfg(pydantic.BaseModel, extra="forbid"): ) # package versions - versions: List[CfgVersion] = pydantic.Field(default_factory=list) + versions: list[CfgVersion] = pydantic.Field(default_factory=list) # resolve - scopes: List[CfgScope] = pydantic.Field(default_factory=dict) + scopes: list[CfgScope] = pydantic.Field(default_factory=dict) # outputs - resolvers: List[CfgResolver] = pydantic.Field(default_factory=list) + resolvers: list[CfgResolver] = pydantic.Field(default_factory=list) @pydantic.field_validator("versions", mode="before") @classmethod @@ -1058,7 +1058,7 @@ class _PyprojectToml(pydantic.BaseModel, extra="ignore"): def pydeps( *, - config_path: Union[str, Path], + config_path: str | Path, dry_run: bool = False, ) -> bool: # 1. get absolute diff --git a/pydependence/_core/module_data.py b/pydependence/_core/module_data.py index 0029539..a11ffa5 100644 --- a/pydependence/_core/module_data.py +++ b/pydependence/_core/module_data.py @@ -26,7 +26,8 @@ import warnings from importlib.machinery import FileFinder from pathlib import Path -from typing import Iterator, NamedTuple +from typing import NamedTuple +from collections.abc import Iterator from pydependence._core.utils import assert_valid_import_name, assert_valid_tag diff --git a/pydependence/_core/module_imports_ast.py b/pydependence/_core/module_imports_ast.py index 61903e7..b2bdc4c 100644 --- a/pydependence/_core/module_imports_ast.py +++ b/pydependence/_core/module_imports_ast.py @@ -29,7 +29,7 @@ import warnings from collections import Counter, defaultdict from enum import Enum -from typing import DefaultDict, Dict, List, Literal, Optional, Tuple +from typing import DefaultDict, Dict, List, Literal, Optional from pydependence._core.module_data import ModuleMetadata from pydependence._core.utils import assert_valid_import_name, assert_valid_module_path @@ -217,7 +217,7 @@ class LocImportInfo(BasicImportInfo): # debug lineno: int col_offset: int - stack_type_names: Tuple[str, ...] + stack_type_names: tuple[str, ...] # relative import is_relative: bool diff --git a/pydependence/_core/modules_scope.py b/pydependence/_core/modules_scope.py index e41aa24..9808222 100644 --- a/pydependence/_core/modules_scope.py +++ b/pydependence/_core/modules_scope.py @@ -27,15 +27,12 @@ from pathlib import Path from typing import ( Dict, - Iterable, - Iterator, List, NamedTuple, Optional, - Sequence, - Set, Tuple, ) +from collections.abc import Iterable, Iterator, Sequence import networkx as nx @@ -229,7 +226,7 @@ def add_modules_from_scope(self, search_space: "ModulesScope") -> "ModulesScope" return self._merge_module_graph(graph=search_space._module_graph) def add_modules_from_raw_imports( - self, imports: List[str], tag: str + self, imports: list[str], tag: str ) -> "ModulesScope": g = nx.DiGraph() for imp in imports: @@ -239,7 +236,7 @@ def add_modules_from_raw_imports( def add_modules_from_search_path( self, search_path: Path, - tag: Optional[str] = None, + tag: str | None = None, unreachable_mode: UnreachableModeEnum = UnreachableModeEnum.error, ) -> "ModulesScope": if tag is None: @@ -258,7 +255,7 @@ def add_modules_from_search_path( def add_modules_from_package_path( self, package_path: Path, - tag: Optional[str] = None, + tag: str | None = None, unreachable_mode: UnreachableModeEnum = UnreachableModeEnum.error, ) -> "ModulesScope": if tag is None: @@ -303,7 +300,7 @@ def is_scope_subset(self, other: "ModulesScope") -> bool: def is_scope_conflicts(self, other: "ModulesScope") -> bool: return bool(self._module_graph.nodes & other._module_graph.nodes) - def get_scope_conflicts(self, other: "ModulesScope") -> Set[str]: + def get_scope_conflicts(self, other: "ModulesScope") -> set[str]: return set(self._module_graph.nodes & other._module_graph.nodes) # ~=~=~ FILTER MODULES ~=~=~ # diff --git a/pydependence/_core/requirements_map.py b/pydependence/_core/requirements_map.py index 2fd2b90..c9177e4 100644 --- a/pydependence/_core/requirements_map.py +++ b/pydependence/_core/requirements_map.py @@ -25,7 +25,7 @@ import dataclasses import functools import warnings -from typing import TYPE_CHECKING, Dict, List, NamedTuple, Optional, Set, Union +from typing import TYPE_CHECKING, Dict, List, NamedTuple, Optional, Union from pydependence._core.builtin import BUILTIN_MODULE_NAMES from pydependence._core.module_imports_ast import ( @@ -156,7 +156,7 @@ class MappedRequirementInfo(NamedTuple): @dataclasses.dataclass class MappedRequirementSource: source_module: str - source_module_imports: List[BasicImportInfo] + source_module_imports: list[BasicImportInfo] def to_output_requirement_source(self): return OutMappedRequirementSource( @@ -171,9 +171,9 @@ def to_output_requirement_source(self): @dataclasses.dataclass class MappedRequirement: requirement: str # mapped name - sources: Dict[str, MappedRequirementSource] # k == v.source_module + sources: dict[str, MappedRequirementSource] # k == v.source_module - def get_sorted_sources(self) -> List[MappedRequirementSource]: + def get_sorted_sources(self) -> list[MappedRequirementSource]: return sorted(self.sources.values(), key=lambda x: x.source_module) def to_output_requirement(self): @@ -188,10 +188,10 @@ def to_output_requirement(self): @dataclasses.dataclass class MappedRequirements: - requirements: Dict[str, MappedRequirement] # k == v.requirement - resolver_name: Optional[str] = None + requirements: dict[str, MappedRequirement] # k == v.requirement + resolver_name: str | None = None - def get_sorted_requirements(self) -> List[MappedRequirement]: + def get_sorted_requirements(self) -> list[MappedRequirement]: return sorted( self.requirements.values(), key=lambda x: x.requirement, @@ -213,7 +213,7 @@ def to_output_requirements(self): class NoConfiguredRequirementMappingError(ValueError): - def __init__(self, msg: str, imports: Set[str]): + def __init__(self, msg: str, imports: set[str]): self.msg = msg self.imports = imports super().__init__(msg) @@ -371,8 +371,8 @@ def generate_mapped_requirements( *, requirements_env: "Optional[str]" = None, strict: bool = False, - raw: List[str] = None, - resolver_name: Optional[str] = None, + raw: list[str] = None, + resolver_name: str | None = None, ) -> "MappedRequirements": """ Map imports to requirements, returning the imports grouped by the requirement. @@ -458,7 +458,7 @@ def generate_output_requirements( *, requirements_env: "Optional[str]" = None, strict: bool = False, - resolver_name: Optional[str] = None, + resolver_name: str | None = None, ) -> "OutMappedRequirements": """ :raises NoConfiguredRequirementMappingError: if no requirement is found for any import, but only if strict mode is enabled. diff --git a/pydependence/_core/requirements_out.py b/pydependence/_core/requirements_out.py index a3bee79..8459303 100644 --- a/pydependence/_core/requirements_out.py +++ b/pydependence/_core/requirements_out.py @@ -25,7 +25,7 @@ import dataclasses from collections import defaultdict -from typing import List, NamedTuple, Optional, Tuple +from typing import List, NamedTuple, Tuple # ========================================================================= # # REQUIREMENTS MAPPER # @@ -58,7 +58,7 @@ def anno_str(self) -> str: @dataclasses.dataclass class OutMappedRequirement: requirement: str - sources: List[OutMappedRequirementSource] + sources: list[OutMappedRequirementSource] @property def all_lazy(self) -> bool: @@ -123,8 +123,8 @@ def get_annotations_string( @dataclasses.dataclass class OutMappedRequirements: - requirements: List[OutMappedRequirement] - resolver_name: Optional[str] = None + requirements: list[OutMappedRequirement] + resolver_name: str | None = None _AUTOGEN_NOTICE = "[AUTOGEN] by pydependence **DO NOT EDIT** [AUTOGEN]" _AUTOGEN_NOTICE_NAMED = ( diff --git a/pyproject.toml b/pyproject.toml index 7b5fbfc..2ca8478 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -115,8 +115,6 @@ dependencies = [ # ← pydependence._cli "stdlib_list", # ← pydependence._core.builtin - "typing-extensions", - # ← pydependence._cli ] # - - - - - - - - - - - - - - - - - - - - - - # @@ -153,8 +151,6 @@ test = [ # ← [L] pydependence._core.requirements_out # ← [L] pydependence._core.utils # ← [L] tests.test_module_data - "typing-extensions", - # ← pydependence._cli ] some = [ # [AUTOGEN] by pydependence resolver 'some' **DO NOT EDIT** [AUTOGEN] @@ -167,8 +163,6 @@ some = [ # ← pydependence._cli "stdlib_list", # ← pydependence._core.builtin - "typing-extensions", - # ← pydependence._cli ] all = [ # [AUTOGEN] by pydependence resolver 'all' **DO NOT EDIT** [AUTOGEN] @@ -184,8 +178,6 @@ all = [ "tomlkit", # [L] # ← [L] pydependence._core.requirements_out # ← [L] pydependence._core.utils - "typing-extensions", - # ← pydependence._cli ] core = [ # [AUTOGEN] by pydependence resolver 'core' **DO NOT EDIT** [AUTOGEN] @@ -209,8 +201,6 @@ example-core-no-lazy = [ # ← pydependence._cli "stdlib_list", # ← pydependence._core.builtin - "typing-extensions", - # ← pydependence._cli ] example-legacy = [ # [AUTOGEN] by pydependence resolver 'example-legacy' **DO NOT EDIT** [AUTOGEN] @@ -226,6 +216,4 @@ example-legacy = [ "tomlkit", # [L] # ← [L] pydependence._core.requirements_out # ← [L] pydependence._core.utils - "typing-extensions", - # ← pydependence._cli ] From a8db156444eb051bad710e5890e58bb26dd4f32e Mon Sep 17 00:00:00 2001 From: Nathan Michlo Date: Fri, 26 Sep 2025 17:50:16 +0200 Subject: [PATCH 6/9] disable and test --- .github/workflows/python-test.yml | 12 +++++++----- .pre-commit-config.yaml | 10 +++++----- pyproject.toml | 23 ++--------------------- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index 6ea0a29..77a94c0 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -16,11 +16,13 @@ jobs: matrix: os: [ubuntu-latest] # [ubuntu-latest, windows-latest, macos-latest] python-version: [ - "3.8", - "3.9", - "3.10", - "3.11", - "3.12", + # "3.8", # 2019-10 -> 2024-10 + # "3.9", # 2020-10 -> 2025-10 + # "3.10", # 2021-10 -> 2026-10 + # "3.11", # 2022-10 -> 2027-10 tomllib + # "3.12", # 2023-10 -> 2028-10 + "3.13", # 2024-10 -> 2029-10 + # "3.14", # 2025-10 -> 2030-10 ] steps: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2e15745..03868a0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,8 +31,8 @@ repos: - id: ruff-format # this repo - - repo: https://github.com/nmichlo/pydependence - rev: v0.5.0 - hooks: - - id: pydependence - args: ["pyproject.toml"] + # - repo: https://github.com/nmichlo/pydependence + # rev: v0.5.0 + # hooks: + # - id: pydependence + # args: ["pyproject.toml"] diff --git a/pyproject.toml b/pyproject.toml index 2ca8478..5f9c6cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,11 +87,7 @@ authors = [{name = "Nathan Michlo", email = "nathanjmichlo@gmail.com"}] readme = "README.md" license = {file="LICENSE"} classifiers = [ - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ] @@ -103,7 +99,7 @@ classifiers = [ # !!! do not modify this section manually !!! # # - - - - - - - - - - - - - - - - - - - - - - # -requires-python = ">=3.8" +requires-python = ">=3.13" dependencies = [ # [AUTOGEN] by pydependence resolver 'pydependence' **DO NOT EDIT** [AUTOGEN] "networkx", @@ -202,18 +198,3 @@ example-core-no-lazy = [ "stdlib_list", # ← pydependence._core.builtin ] -example-legacy = [ - # [AUTOGEN] by pydependence resolver 'example-legacy' **DO NOT EDIT** [AUTOGEN] - "networkx", - # ← pydependence._core.modules_resolver - # ← pydependence._core.modules_scope - "packaging", - # ← pydependence._cli - "pydantic<2.0.0,>=1.0.0", - # ← pydependence._cli - "stdlib_list", - # ← pydependence._core.builtin - "tomlkit", # [L] - # ← [L] pydependence._core.requirements_out - # ← [L] pydependence._core.utils -] From dbff2989d2003a13de62aa2cf9de91a2692eadbd Mon Sep 17 00:00:00 2001 From: Nathan Michlo Date: Fri, 26 Sep 2025 18:18:20 +0200 Subject: [PATCH 7/9] update license --- LICENSE | 2 +- pydependence/__init__.py | 25 ++------------- pydependence/__main__.py | 26 ++-------------- pydependence/_cli.py | 25 ++------------- pydependence/_colors.py | 25 ++------------- pydependence/_core/__init__.py | 25 ++------------- pydependence/_core/builtin.py | 34 ++++----------------- pydependence/_core/module_data.py | 25 ++------------- pydependence/_core/module_imports_ast.py | 25 ++------------- pydependence/_core/module_imports_loader.py | 25 ++------------- pydependence/_core/modules_resolver.py | 25 ++------------- pydependence/_core/modules_scope.py | 26 ++-------------- pydependence/_core/requirements_map.py | 26 ++-------------- pydependence/_core/requirements_out.py | 26 ++-------------- pydependence/_core/utils.py | 25 ++------------- tests/__init__.py | 25 ++------------- tests/test_module_data.py | 25 ++------------- tests/test_utils.py | 25 ++------------- 18 files changed, 41 insertions(+), 399 deletions(-) diff --git a/LICENSE b/LICENSE index 7529b23..e672c10 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Nathan Juraj Michlo +Copyright (c) 2024 Nathan Juraj Michlo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/pydependence/__init__.py b/pydependence/__init__.py index 38df5a2..5ff725a 100644 --- a/pydependence/__init__.py +++ b/pydependence/__init__.py @@ -1,23 +1,2 @@ -# ============================================================================== # -# MIT License # -# # -# Copyright (c) 2024 Nathan Juraj Michlo # -# # -# Permission is hereby granted, free of charge, to any person obtaining a copy # -# of this software and associated documentation files (the "Software"), to deal # -# in the Software without restriction, including without limitation the rights # -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # -# copies of the Software, and to permit persons to whom the Software is # -# furnished to do so, subject to the following conditions: # -# # -# The above copyright notice and this permission notice shall be included in all # -# copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # -# SOFTWARE. # -# ============================================================================== # +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Nathan Juraj Michlo diff --git a/pydependence/__main__.py b/pydependence/__main__.py index 7d212f8..2a58d78 100644 --- a/pydependence/__main__.py +++ b/pydependence/__main__.py @@ -1,27 +1,5 @@ -# ============================================================================== # -# MIT License # -# # -# Copyright (c) 2024 Nathan Juraj Michlo # -# # -# Permission is hereby granted, free of charge, to any person obtaining a copy # -# of this software and associated documentation files (the "Software"), to deal # -# in the Software without restriction, including without limitation the rights # -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # -# copies of the Software, and to permit persons to whom the Software is # -# furnished to do so, subject to the following conditions: # -# # -# The above copyright notice and this permission notice shall be included in all # -# copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # -# SOFTWARE. # -# ============================================================================== # - +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Nathan Juraj Michlo import argparse import logging diff --git a/pydependence/_cli.py b/pydependence/_cli.py index bc5a666..9944f0f 100644 --- a/pydependence/_cli.py +++ b/pydependence/_cli.py @@ -1,26 +1,5 @@ -# ============================================================================== # -# MIT License # -# # -# Copyright (c) 2024 Nathan Juraj Michlo # -# # -# Permission is hereby granted, free of charge, to any person obtaining a copy # -# of this software and associated documentation files (the "Software"), to deal # -# in the Software without restriction, including without limitation the rights # -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # -# copies of the Software, and to permit persons to whom the Software is # -# furnished to do so, subject to the following conditions: # -# # -# The above copyright notice and this permission notice shall be included in all # -# copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # -# SOFTWARE. # -# ============================================================================== # +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Nathan Juraj Michlo import contextlib import logging diff --git a/pydependence/_colors.py b/pydependence/_colors.py index 364b6e6..a29fa41 100644 --- a/pydependence/_colors.py +++ b/pydependence/_colors.py @@ -1,26 +1,5 @@ -# ============================================================================== # -# MIT License # -# # -# Copyright (c) 2024 Nathan Juraj Michlo # -# # -# Permission is hereby granted, free of charge, to any person obtaining a copy # -# of this software and associated documentation files (the "Software"), to deal # -# in the Software without restriction, including without limitation the rights # -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # -# copies of the Software, and to permit persons to whom the Software is # -# furnished to do so, subject to the following conditions: # -# # -# The above copyright notice and this permission notice shall be included in all # -# copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # -# SOFTWARE. # -# ============================================================================== # +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Nathan Juraj Michlo # ========================================================================= # # Ansi Colors # diff --git a/pydependence/_core/__init__.py b/pydependence/_core/__init__.py index 38df5a2..5ff725a 100644 --- a/pydependence/_core/__init__.py +++ b/pydependence/_core/__init__.py @@ -1,23 +1,2 @@ -# ============================================================================== # -# MIT License # -# # -# Copyright (c) 2024 Nathan Juraj Michlo # -# # -# Permission is hereby granted, free of charge, to any person obtaining a copy # -# of this software and associated documentation files (the "Software"), to deal # -# in the Software without restriction, including without limitation the rights # -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # -# copies of the Software, and to permit persons to whom the Software is # -# furnished to do so, subject to the following conditions: # -# # -# The above copyright notice and this permission notice shall be included in all # -# copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # -# SOFTWARE. # -# ============================================================================== # +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Nathan Juraj Michlo diff --git a/pydependence/_core/builtin.py b/pydependence/_core/builtin.py index 9452344..a731c34 100644 --- a/pydependence/_core/builtin.py +++ b/pydependence/_core/builtin.py @@ -1,34 +1,12 @@ -# ============================================================================== # -# MIT License # -# # -# Copyright (c) 2024 Nathan Juraj Michlo # -# # -# Permission is hereby granted, free of charge, to any person obtaining a copy # -# of this software and associated documentation files (the "Software"), to deal # -# in the Software without restriction, including without limitation the rights # -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # -# copies of the Software, and to permit persons to whom the Software is # -# furnished to do so, subject to the following conditions: # -# # -# The above copyright notice and this permission notice shall be included in all # -# copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # -# SOFTWARE. # -# ============================================================================== # +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Nathan Juraj Michlo - -from stdlib_list import stdlib_list as _stdlib_list +import sys # check the python version -# if sys.version_info < (3, 10): -# print("please use python >= 3.10") -# exit(1) +if sys.version_info < (3, 10): + print("please use python >= 3.10") + exit(1) # TODO: for python 3.10 and up, can use `sys.stdlib_module_names` or `sys.builtin_module_names` diff --git a/pydependence/_core/module_data.py b/pydependence/_core/module_data.py index a11ffa5..d4710cd 100644 --- a/pydependence/_core/module_data.py +++ b/pydependence/_core/module_data.py @@ -1,26 +1,5 @@ -# ============================================================================== # -# MIT License # -# # -# Copyright (c) 2024 Nathan Juraj Michlo # -# # -# Permission is hereby granted, free of charge, to any person obtaining a copy # -# of this software and associated documentation files (the "Software"), to deal # -# in the Software without restriction, including without limitation the rights # -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # -# copies of the Software, and to permit persons to whom the Software is # -# furnished to do so, subject to the following conditions: # -# # -# The above copyright notice and this permission notice shall be included in all # -# copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # -# SOFTWARE. # -# ============================================================================== # +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Nathan Juraj Michlo import pkgutil import warnings diff --git a/pydependence/_core/module_imports_ast.py b/pydependence/_core/module_imports_ast.py index b2bdc4c..238e314 100644 --- a/pydependence/_core/module_imports_ast.py +++ b/pydependence/_core/module_imports_ast.py @@ -1,26 +1,5 @@ -# ============================================================================== # -# MIT License # -# # -# Copyright (c) 2024 Nathan Juraj Michlo # -# # -# Permission is hereby granted, free of charge, to any person obtaining a copy # -# of this software and associated documentation files (the "Software"), to deal # -# in the Software without restriction, including without limitation the rights # -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # -# copies of the Software, and to permit persons to whom the Software is # -# furnished to do so, subject to the following conditions: # -# # -# The above copyright notice and this permission notice shall be included in all # -# copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # -# SOFTWARE. # -# ============================================================================== # +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Nathan Juraj Michlo import ast diff --git a/pydependence/_core/module_imports_loader.py b/pydependence/_core/module_imports_loader.py index 5d17aea..e9ac83a 100644 --- a/pydependence/_core/module_imports_loader.py +++ b/pydependence/_core/module_imports_loader.py @@ -1,26 +1,5 @@ -# ============================================================================== # -# MIT License # -# # -# Copyright (c) 2024 Nathan Juraj Michlo # -# # -# Permission is hereby granted, free of charge, to any person obtaining a copy # -# of this software and associated documentation files (the "Software"), to deal # -# in the Software without restriction, including without limitation the rights # -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # -# copies of the Software, and to permit persons to whom the Software is # -# furnished to do so, subject to the following conditions: # -# # -# The above copyright notice and this permission notice shall be included in all # -# copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # -# SOFTWARE. # -# ============================================================================== # +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Nathan Juraj Michlo import dataclasses diff --git a/pydependence/_core/modules_resolver.py b/pydependence/_core/modules_resolver.py index 7fcd30c..951bfba 100644 --- a/pydependence/_core/modules_resolver.py +++ b/pydependence/_core/modules_resolver.py @@ -1,26 +1,5 @@ -# ============================================================================== # -# MIT License # -# # -# Copyright (c) 2024 Nathan Juraj Michlo # -# # -# Permission is hereby granted, free of charge, to any person obtaining a copy # -# of this software and associated documentation files (the "Software"), to deal # -# in the Software without restriction, including without limitation the rights # -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # -# copies of the Software, and to permit persons to whom the Software is # -# furnished to do so, subject to the following conditions: # -# # -# The above copyright notice and this permission notice shall be included in all # -# copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # -# SOFTWARE. # -# ============================================================================== # +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Nathan Juraj Michlo import warnings from collections import defaultdict diff --git a/pydependence/_core/modules_scope.py b/pydependence/_core/modules_scope.py index 9808222..26df263 100644 --- a/pydependence/_core/modules_scope.py +++ b/pydependence/_core/modules_scope.py @@ -1,26 +1,6 @@ -# ============================================================================== # -# MIT License # -# # -# Copyright (c) 2024 Nathan Juraj Michlo # -# # -# Permission is hereby granted, free of charge, to any person obtaining a copy # -# of this software and associated documentation files (the "Software"), to deal # -# in the Software without restriction, including without limitation the rights # -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # -# copies of the Software, and to permit persons to whom the Software is # -# furnished to do so, subject to the following conditions: # -# # -# The above copyright notice and this permission notice shall be included in all # -# copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # -# SOFTWARE. # -# ============================================================================== # +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Nathan Juraj Michlo + import warnings from collections import defaultdict from enum import Enum diff --git a/pydependence/_core/requirements_map.py b/pydependence/_core/requirements_map.py index c9177e4..e6c46a6 100644 --- a/pydependence/_core/requirements_map.py +++ b/pydependence/_core/requirements_map.py @@ -1,26 +1,6 @@ -# ============================================================================== # -# MIT License # -# # -# Copyright (c) 2024 Nathan Juraj Michlo # -# # -# Permission is hereby granted, free of charge, to any person obtaining a copy # -# of this software and associated documentation files (the "Software"), to deal # -# in the Software without restriction, including without limitation the rights # -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # -# copies of the Software, and to permit persons to whom the Software is # -# furnished to do so, subject to the following conditions: # -# # -# The above copyright notice and this permission notice shall be included in all # -# copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # -# SOFTWARE. # -# ============================================================================== # +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Nathan Juraj Michlo + import abc import dataclasses import functools diff --git a/pydependence/_core/requirements_out.py b/pydependence/_core/requirements_out.py index 8459303..eeb6414 100644 --- a/pydependence/_core/requirements_out.py +++ b/pydependence/_core/requirements_out.py @@ -1,27 +1,5 @@ -# ============================================================================== # -# MIT License # -# # -# Copyright (c) 2024 Nathan Juraj Michlo # -# # -# Permission is hereby granted, free of charge, to any person obtaining a copy # -# of this software and associated documentation files (the "Software"), to deal # -# in the Software without restriction, including without limitation the rights # -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # -# copies of the Software, and to permit persons to whom the Software is # -# furnished to do so, subject to the following conditions: # -# # -# The above copyright notice and this permission notice shall be included in all # -# copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # -# SOFTWARE. # -# ============================================================================== # - +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Nathan Juraj Michlo import dataclasses from collections import defaultdict diff --git a/pydependence/_core/utils.py b/pydependence/_core/utils.py index c66b751..a41389a 100644 --- a/pydependence/_core/utils.py +++ b/pydependence/_core/utils.py @@ -1,26 +1,5 @@ -# ============================================================================== # -# MIT License # -# # -# Copyright (c) 2024 Nathan Juraj Michlo # -# # -# Permission is hereby granted, free of charge, to any person obtaining a copy # -# of this software and associated documentation files (the "Software"), to deal # -# in the Software without restriction, including without limitation the rights # -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # -# copies of the Software, and to permit persons to whom the Software is # -# furnished to do so, subject to the following conditions: # -# # -# The above copyright notice and this permission notice shall be included in all # -# copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # -# SOFTWARE. # -# ============================================================================== # +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Nathan Juraj Michlo from pathlib import Path from typing import List, TYPE_CHECKING, Union diff --git a/tests/__init__.py b/tests/__init__.py index 38df5a2..5ff725a 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,23 +1,2 @@ -# ============================================================================== # -# MIT License # -# # -# Copyright (c) 2024 Nathan Juraj Michlo # -# # -# Permission is hereby granted, free of charge, to any person obtaining a copy # -# of this software and associated documentation files (the "Software"), to deal # -# in the Software without restriction, including without limitation the rights # -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # -# copies of the Software, and to permit persons to whom the Software is # -# furnished to do so, subject to the following conditions: # -# # -# The above copyright notice and this permission notice shall be included in all # -# copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # -# SOFTWARE. # -# ============================================================================== # +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Nathan Juraj Michlo diff --git a/tests/test_module_data.py b/tests/test_module_data.py index ec07d42..57a70f0 100644 --- a/tests/test_module_data.py +++ b/tests/test_module_data.py @@ -1,26 +1,5 @@ -# ============================================================================== # -# MIT License # -# # -# Copyright (c) 2024 Nathan Juraj Michlo # -# # -# Permission is hereby granted, free of charge, to any person obtaining a copy # -# of this software and associated documentation files (the "Software"), to deal # -# in the Software without restriction, including without limitation the rights # -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # -# copies of the Software, and to permit persons to whom the Software is # -# furnished to do so, subject to the following conditions: # -# # -# The above copyright notice and this permission notice shall be included in all # -# copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # -# SOFTWARE. # -# ============================================================================== # +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Nathan Juraj Michlo import sys from pathlib import Path diff --git a/tests/test_utils.py b/tests/test_utils.py index 566c270..eab6276 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,26 +1,5 @@ -# ============================================================================== # -# MIT License # -# # -# Copyright (c) 2024 Nathan Juraj Michlo # -# # -# Permission is hereby granted, free of charge, to any person obtaining a copy # -# of this software and associated documentation files (the "Software"), to deal # -# in the Software without restriction, including without limitation the rights # -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # -# copies of the Software, and to permit persons to whom the Software is # -# furnished to do so, subject to the following conditions: # -# # -# The above copyright notice and this permission notice shall be included in all # -# copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # -# SOFTWARE. # -# ============================================================================== # +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Nathan Juraj Michlo from pathlib import Path From 8fb7f5200b8df4dbd131d75f47594065805edcb2 Mon Sep 17 00:00:00 2001 From: Nathan Michlo Date: Fri, 26 Sep 2025 18:22:37 +0200 Subject: [PATCH 8/9] fix exports & update checks python 3.13 --- pydependence/_core/builtin.py | 20 +++++++------------- pydependence/_core/module_data.py | 7 ++++--- pydependence/_core/module_imports_ast.py | 12 +++++------- pydependence/_core/module_imports_loader.py | 10 ++++------ pydependence/_core/modules_scope.py | 15 +++++++-------- pydependence/_core/utils.py | 15 +++++++-------- 6 files changed, 34 insertions(+), 45 deletions(-) diff --git a/pydependence/_core/builtin.py b/pydependence/_core/builtin.py index a731c34..a30e8fb 100644 --- a/pydependence/_core/builtin.py +++ b/pydependence/_core/builtin.py @@ -1,21 +1,15 @@ # SPDX-License-Identifier: MIT # Copyright (c) 2024 Nathan Juraj Michlo +__all__ = [ + "BUILTIN_MODULE_NAMES", +] + import sys # check the python version -if sys.version_info < (3, 10): - print("please use python >= 3.10") - exit(1) - - -# TODO: for python 3.10 and up, can use `sys.stdlib_module_names` or `sys.builtin_module_names` BUILTIN_MODULE_NAMES = { - # "__main__", - # *sys.builtin_module_names, - # *sys.stdlib_module_names, - *_stdlib_list(), + "__main__", + *sys.builtin_module_names, + *sys.stdlib_module_names, } - - -__all__ = ("BUILTIN_MODULE_NAMES",) diff --git a/pydependence/_core/module_data.py b/pydependence/_core/module_data.py index d4710cd..e53fac4 100644 --- a/pydependence/_core/module_data.py +++ b/pydependence/_core/module_data.py @@ -1,6 +1,10 @@ # SPDX-License-Identifier: MIT # Copyright (c) 2024 Nathan Juraj Michlo +__all__ = [ + "ModuleMetadata", +] + import pkgutil import warnings from importlib.machinery import FileFinder @@ -129,6 +133,3 @@ def _visit(p: Path): # ========================================================================= # # END # # ========================================================================= # - - -__all__ = ("ModuleMetadata",) diff --git a/pydependence/_core/module_imports_ast.py b/pydependence/_core/module_imports_ast.py index 238e314..4d59c69 100644 --- a/pydependence/_core/module_imports_ast.py +++ b/pydependence/_core/module_imports_ast.py @@ -1,6 +1,11 @@ # SPDX-License-Identifier: MIT # Copyright (c) 2024 Nathan Juraj Michlo +__all__ = [ + "load_imports_from_module_info", + "LocImportInfo", + "ImportSourceEnum", +] import ast import dataclasses @@ -450,13 +455,6 @@ def load_imports_from_module_info( # ========================================================================= # -__all__ = ( - "load_imports_from_module_info", - "LocImportInfo", - "ImportSourceEnum", -) - - # PYTHON VERSION: 3.10 # { # # mod = Module(stmt* body, type_ignore* type_ignores) diff --git a/pydependence/_core/module_imports_loader.py b/pydependence/_core/module_imports_loader.py index e9ac83a..fe8a8d3 100644 --- a/pydependence/_core/module_imports_loader.py +++ b/pydependence/_core/module_imports_loader.py @@ -1,6 +1,10 @@ # SPDX-License-Identifier: MIT # Copyright (c) 2024 Nathan Juraj Michlo +__all__ = [ + "ModuleImports", + "DEFAULT_MODULE_IMPORTS_LOADER", +] import dataclasses from typing import Dict, List, Tuple @@ -64,9 +68,3 @@ def load_module_imports(self, module_info: ModuleMetadata) -> ModuleImports: # ========================================================================= # # END # # ========================================================================= # - - -__all__ = ( - "ModuleImports", - "DEFAULT_MODULE_IMPORTS_LOADER", -) diff --git a/pydependence/_core/modules_scope.py b/pydependence/_core/modules_scope.py index 26df263..d1df764 100644 --- a/pydependence/_core/modules_scope.py +++ b/pydependence/_core/modules_scope.py @@ -1,6 +1,13 @@ # SPDX-License-Identifier: MIT # Copyright (c) 2024 Nathan Juraj Michlo +__all__ = [ + "DuplicateModuleNamesError", + "ModulesScope", + "RestrictMode", + "RestrictOp", +] + import warnings from collections import defaultdict from enum import Enum @@ -364,11 +371,3 @@ def resolve_imports( # ========================================================================= # # END # # ========================================================================= # - - -__all__ = ( - "DuplicateModuleNamesError", - "ModulesScope", - "RestrictMode", - "RestrictOp", -) diff --git a/pydependence/_core/utils.py b/pydependence/_core/utils.py index a41389a..4fd6702 100644 --- a/pydependence/_core/utils.py +++ b/pydependence/_core/utils.py @@ -1,6 +1,13 @@ # SPDX-License-Identifier: MIT # Copyright (c) 2024 Nathan Juraj Michlo +__all__ = [ + "assert_valid_module_path", + "assert_valid_import_name", + "apply_root_to_path_str", + "load_toml_document", +] + from pathlib import Path from typing import List, TYPE_CHECKING, Union @@ -150,11 +157,3 @@ def toml_file_replace_array( # ========================================================================= # # END # # ========================================================================= # - - -__all__ = ( - "assert_valid_module_path", - "assert_valid_import_name", - "apply_root_to_path_str", - "load_toml_document", -) From bb5965586317d254da2fe223c5cb0c124efe6d85 Mon Sep 17 00:00:00 2001 From: Nathan Michlo Date: Fri, 26 Sep 2025 18:32:09 +0200 Subject: [PATCH 9/9] fixes --- README.md | 17 +++++++++++++++++ tests/test_module_data.py | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1054397..9547010 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,23 @@ python -m pydependence --help python -m pydependence ``` +### Local Development + +Easiest way is to use `uv` + +```bash +pip install uv + +# clone repo +git clone https://github.com/nmichlo/pydependence +cd ./pydependence + +# setup pre-commit +uvx --with .[dev] pre-commit install +# run tests +uvx --with .[dev,test] pytest +``` + ---------------------- ## Help diff --git a/tests/test_module_data.py b/tests/test_module_data.py index 57a70f0..b4d591e 100644 --- a/tests/test_module_data.py +++ b/tests/test_module_data.py @@ -851,7 +851,7 @@ def test_requirement_mapping(): # test def m(x): - mapper.map_import_to_requirement(x, requirements_env="default") + return mapper.map_import_to_requirement(x, requirements_env="default") # in order: assert m("A.a3.a3i") == "glob_Aa3" @@ -866,7 +866,7 @@ def m(x): # test alt def m(x): - mapper.map_import_to_requirement(x, requirements_env="asdf") + return mapper.map_import_to_requirement(x, requirements_env="asdf") # in order: assert m("A.a3.a3i") == "ALT_glob_Aa3"