Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions duties.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Development tasks."""

from __future__ import annotations

import importlib
import os
import re
Expand All @@ -8,7 +10,7 @@
from contextlib import suppress
from io import StringIO
from pathlib import Path
from typing import List, Optional, Pattern
from typing import List, Pattern
from urllib.request import urlopen

from duty import duty
Expand All @@ -22,7 +24,7 @@
PTY = not WINDOWS and not CI


def _latest(lines: List[str], regex: Pattern) -> Optional[str]:
def _latest(lines: List[str], regex: Pattern) -> str | None:
for line in lines:
match = regex.search(line)
if match:
Expand Down
4 changes: 2 additions & 2 deletions src/dependenpy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import argparse
import sys
from contextlib import contextmanager
from typing import List, Optional
from typing import List

from colorama import init

Expand Down Expand Up @@ -185,7 +185,7 @@ def _run(opts, dsm):
dsm.print_graph(format=opts.format, output=output, depth=depth, indent=indent)


def main(args: Optional[List[str]] = None) -> int: # noqa: WPS231
def main(args: List[str] | None = None) -> int: # noqa: WPS231
"""
Run the main program.

Expand Down
14 changes: 7 additions & 7 deletions src/dependenpy/dsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ def __init__(
"""
self.base_packages = packages
self.finder = Finder()
self.specs = []
self.not_found = []
self.specs: List[PackageSpec] = []
self.not_found: List[str] = []
self.enforce_init = enforce_init

specs = []
specs: List[PackageSpec] = []
for package in packages:
spec = self.finder.find(package, enforce_init=enforce_init)
spec: PackageSpec | None = self.finder.find(package, enforce_init=enforce_init)
if spec:
specs.append(spec)
else:
Expand Down Expand Up @@ -117,9 +117,9 @@ def __init__(
self,
name: str,
path: str,
dsm: DSM = None,
package: "Package" = None,
limit_to: List[str] = None,
dsm: DSM | None = None,
package: "Package" | None = None,
limit_to: List[str] | None = None,
build_tree: bool = True,
build_dependencies: bool = True,
enforce_init: bool = True,
Expand Down
2 changes: 1 addition & 1 deletion src/dependenpy/finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class Finder(object):
Initialize it with a list of package finder classes (not instances).
"""

def __init__(self, finders: List[Type] = None):
def __init__(self, finders: List[Type] | None = None):
"""
Initialization method.

Expand Down
2 changes: 1 addition & 1 deletion src/dependenpy/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class PrintMixin(object):
"""Print mixin class."""

def print(self, format: str | None = TEXT, output: IO = sys.stdout, **kwargs: Any): # noqa: A002,A003
def print(self, format: str = TEXT, output: IO = sys.stdout, **kwargs: Any): # noqa: A002,A003
"""
Print the object in a file or on standard output by default.

Expand Down
7 changes: 4 additions & 3 deletions src/dependenpy/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys
from typing import IO, TYPE_CHECKING, Any

from dependenpy import helpers
from dependenpy.structures import Graph, Matrix, TreeMap

if TYPE_CHECKING:
Expand Down Expand Up @@ -246,7 +247,7 @@ def build_dependencies(self):
package.build_dependencies()

def print_graph(
self, format: str | None = None, output: IO = sys.stdout, depth: int = 0, **kwargs: Any # noqa: A002
self, format: str = helpers.TEXT, output: IO = sys.stdout, depth: int = 0, **kwargs: Any # noqa: A002
):
"""
Print the graph for self's nodes.
Expand All @@ -261,7 +262,7 @@ def print_graph(
graph.print(format=format, output=output, **kwargs)

def print_matrix(
self, format: str | None = None, output: IO = sys.stdout, depth: int = 0, **kwargs: Any # noqa: A002
self, format: str = helpers.TEXT, output: IO = sys.stdout, depth: int = 0, **kwargs: Any # noqa: A002
):
"""
Print the matrix for self's nodes.
Expand All @@ -275,7 +276,7 @@ def print_matrix(
matrix = self.as_matrix(depth=depth)
matrix.print(format=format, output=output, **kwargs)

def print_treemap(self, format: str | None = None, output: IO = sys.stdout, **kwargs: Any): # noqa: A002
def print_treemap(self, format: str = helpers.TEXT, output: IO = sys.stdout, **kwargs: Any): # noqa: A002
"""
Print the matrix for self's nodes.

Expand Down
2 changes: 1 addition & 1 deletion src/dependenpy/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class InternalDependencies(archan.Provider): # type: ignore # noqa: WPS440
archan.Argument("depth", int, "The depth of the matrix to generate."),
)

def get_data(self, packages: list[str], enforce_init: bool = True, depth: int = None) -> archan.DSM:
def get_data(self, packages: list[str], enforce_init: bool = True, depth: int | None = None) -> archan.DSM:
"""
Provide matrix data for internal dependencies in a set of packages.

Expand Down
3 changes: 2 additions & 1 deletion tests/test_dependenpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

from dependenpy.cli import main
from dependenpy.dsm import DSM
from dependenpy.dsm import DSM, Module


@pytest.mark.parametrize(
Expand Down Expand Up @@ -53,6 +53,7 @@ def test_inner_imports():
"""Test inner imports."""
dsm = DSM("internal")
module_i = dsm["internal.subpackage_a.subpackage_1.module_i"]
assert isinstance(module_i, Module)
assert len(module_i.dependencies) == 4
assert module_i.cardinal(to=dsm["internal"]) == 3

Expand Down