Skip to content

Commit

Permalink
use ignore_arg in all method decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
xflr6 committed May 13, 2024
1 parent f029709 commit ba6fa6f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion graphviz/_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def deprecate_positional_args(*,
https://docs.python.org/3/library/exceptions.html#DeprecationWarning
https://docs.python.org/3/library/exceptions.html#PendingDeprecationWarning
"""
assert supported_number > 0, f'supported_number at least one: {supported_number!r}'
assert supported_number >= 0, f'supported_number => 0: {supported_number!r}'

if category is None:
def nulldecorator(func):
Expand Down
12 changes: 6 additions & 6 deletions graphviz/dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def _copy_kwargs(self, **kwargs):
body=list(self.body),
strict=self.strict)

@_tools.deprecate_positional_args(supported_number=1)
@_tools.deprecate_positional_args(supported_number=0, ignore_arg='self')
def clear(self, keep_attrs: bool = False) -> None:
"""Reset content to an empty body, clear graph/node/egde_attr mappings.
Expand All @@ -155,7 +155,7 @@ def clear(self, keep_attrs: bool = False) -> None:
a.clear()
self.body.clear()

@_tools.deprecate_positional_args(supported_number=1)
@_tools.deprecate_positional_args(supported_number=0, ignore_arg='self')
def __iter__(self, subgraph: bool = False) -> typing.Iterator[str]:
r"""Yield the DOT source code line by line (as graph or subgraph).
Expand All @@ -181,7 +181,7 @@ def __iter__(self, subgraph: bool = False) -> typing.Iterator[str]:

yield self._tail

@_tools.deprecate_positional_args(supported_number=3)
@_tools.deprecate_positional_args(supported_number=2, ignore_arg='self')
def node(self, name: str,
label: typing.Optional[str] = None,
_attributes=None, **attrs) -> None:
Expand All @@ -203,7 +203,7 @@ def node(self, name: str,
line = self._node(name, attr_list)
self.body.append(line)

@_tools.deprecate_positional_args(supported_number=4)
@_tools.deprecate_positional_args(supported_number=3, ignore_arg='self')
def edge(self, tail_name: str, head_name: str,
label: typing.Optional[str] = None,
_attributes=None, **attrs) -> None:
Expand Down Expand Up @@ -254,7 +254,7 @@ def edges(self, tail_head_iter) -> None:
self.body += [edge(tail=quote(t), head=quote(h))
for t, h in tail_head_iter]

@_tools.deprecate_positional_args(supported_number=2)
@_tools.deprecate_positional_args(supported_number=1, ignore_arg='self')
def attr(self, kw: typing.Optional[str] = None,
_attributes=None, **attrs) -> None:
"""Add a general or graph/node/edge attribute statement.
Expand All @@ -278,7 +278,7 @@ def attr(self, kw: typing.Optional[str] = None,
line = self._attr(kw, attr_list)
self.body.append(line)

@_tools.deprecate_positional_args(supported_number=2)
@_tools.deprecate_positional_args(supported_number=1, ignore_arg='self')
def subgraph(self, graph=None,
name: typing.Optional[str] = None,
comment: typing.Optional[str] = None,
Expand Down
2 changes: 1 addition & 1 deletion graphviz/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class BaseGraph(dot.Dot,
unflattening.Unflatten):
"""Dot language creation and source code rendering."""

@_tools.deprecate_positional_args(supported_number=2)
@_tools.deprecate_positional_args(supported_number=1, ignore_arg='self')
def __init__(self, name: typing.Optional[str] = None,
comment: typing.Optional[str] = None,
filename=None, directory=None,
Expand Down
2 changes: 1 addition & 1 deletion graphviz/piping.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def pipe(self,
engine=engine,
encoding=encoding)

@_tools.deprecate_positional_args(supported_number=2)
@_tools.deprecate_positional_args(supported_number=1, ignore_arg='self')
def _pipe_legacy(self,
format: typing.Optional[str] = None,
renderer: typing.Optional[str] = None,
Expand Down
4 changes: 2 additions & 2 deletions graphviz/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class Render(saving.Save, backend.Render, backend.View):
"""Write source lines to file and render with Graphviz."""

@_tools.deprecate_positional_args(supported_number=2)
@_tools.deprecate_positional_args(supported_number=1, ignore_arg='self')
def render(self,
filename: typing.Union[os.PathLike, str, None] = None,
directory: typing.Union[os.PathLike, str, None] = None,
Expand Down Expand Up @@ -147,7 +147,7 @@ def _view(self, filepath: typing.Union[os.PathLike, str], *,
f' on {backend.viewing.PLATFORM!r} platform')
view_method(filepath, quiet=quiet)

@_tools.deprecate_positional_args(supported_number=2)
@_tools.deprecate_positional_args(supported_number=1, ignore_arg='self')
def view(self,
filename: typing.Union[os.PathLike, str, None] = None,
directory: typing.Union[os.PathLike, str, None] = None,
Expand Down
2 changes: 1 addition & 1 deletion graphviz/unflattening.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class Unflatten(encoding.Encoding, base.Base, backend.Unflatten):
"""Pipe source through the Graphviz *unflatten* preprocessor."""

@_tools.deprecate_positional_args(supported_number=1)
@_tools.deprecate_positional_args(supported_number=0, ignore_arg='self')
def unflatten(self,
stagger: typing.Optional[int] = None,
fanout: bool = False,
Expand Down

0 comments on commit ba6fa6f

Please sign in to comment.