Skip to content

Commit

Permalink
use some positional-only parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
xflr6 committed Jul 22, 2023
1 parent 2242f92 commit 7aa7770
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions graphviz/_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
log = logging.getLogger(__name__)


def attach(object: typing.Any, name: str) -> typing.Callable:
def attach(object: typing.Any, /, name: str) -> typing.Callable:
"""Return a decorator doing ``setattr(object, name)`` with its argument.
>>> spam = type('Spam', (object,), {})() # doctest: +NO_EXE
Expand All @@ -39,7 +39,7 @@ def decorator(func):
return decorator


def mkdirs(filename: typing.Union[os.PathLike, str], *, mode: int = 0o777) -> None:
def mkdirs(filename: typing.Union[os.PathLike, str], /, *, mode: int = 0o777) -> None:
"""Recursively create directories up to the path of ``filename``
as needed."""
dirname = os.path.dirname(filename)
Expand All @@ -49,7 +49,7 @@ def mkdirs(filename: typing.Union[os.PathLike, str], *, mode: int = 0o777) -> No
os.makedirs(dirname, mode=mode, exist_ok=True)


def mapping_items(mapping):
def mapping_items(mapping, /):
"""Return an iterator over the ``mapping`` items,
sort if it's a plain dict.
Expand All @@ -67,17 +67,17 @@ def mapping_items(mapping):


@typing.overload
def promote_pathlike(filepath: typing.Union[os.PathLike, str]) -> pathlib.Path:
def promote_pathlike(filepath: typing.Union[os.PathLike, str], /) -> pathlib.Path:
"""Return path object for path-like-object."""


@typing.overload
def promote_pathlike(filepath: None) -> None:
def promote_pathlike(filepath: None, /) -> None:
"""Return None for None."""


@typing.overload
def promote_pathlike(filepath: typing.Union[os.PathLike, str, None]
def promote_pathlike(filepath: typing.Union[os.PathLike, str, None], /
) -> typing.Optional[pathlib.Path]:
"""Return path object or ``None`` depending on ``filepath``."""

Expand All @@ -92,7 +92,7 @@ def promote_pathlike(filepath: typing.Union[os.PathLike, str, None]
return pathlib.Path(filepath) if filepath is not None else None


def promote_pathlike_directory(directory: typing.Union[os.PathLike, str, None], *,
def promote_pathlike_directory(directory: typing.Union[os.PathLike, str, None], /, *,
default: typing.Union[os.PathLike, str, None] = None,
) -> pathlib.Path:
"""Return path-like object ``directory`` promoted into a path object (default to ``os.curdir``).
Expand Down

0 comments on commit 7aa7770

Please sign in to comment.