Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ruff D rule #982

Open
wants to merge 2 commits into
base: enhancement/rx-docs
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions numbergen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __abs__ (self): return UnaryOperator(self,operator.abs)
}

def pprint(x, *args, **kwargs):
"Pretty-print the provided item, translating operators to their symbols"
"""Pretty-print the provided item, translating operators to their symbols"""
return x.pprint(*args, **kwargs) if hasattr(x,'pprint') else operator_symbols.get(x, repr(x))


Expand Down Expand Up @@ -214,6 +214,7 @@ class Hash:
for __call__ must be specified in the constructor and must stay
constant across calls.
"""

def __init__(self, name, input_count):
self.name = name
self.input_count = input_count
Expand All @@ -224,7 +225,6 @@ def __init__(self, name, input_count):

def _rational(self, val):
"""Convert the given value to a rational, if necessary."""

I32 = 4294967296 # Maximum 32 bit unsigned int (i.e. 'I') value
if isinstance(val, int):
numer, denom = val, 1
Expand Down
21 changes: 14 additions & 7 deletions param/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class ParamWarning(Warning):
"""Base Param Warning"""

class ParamPendingDeprecationWarning(ParamWarning, PendingDeprecationWarning):
"""Param PendingDeprecationWarning
"""
Param PendingDeprecationWarning

This warning type is useful when the warning is not meant to be displayed
to REPL/notebooks users, as DeprecationWarning are displayed when triggered
Expand All @@ -46,14 +47,16 @@ class ParamPendingDeprecationWarning(ParamWarning, PendingDeprecationWarning):


class ParamDeprecationWarning(ParamWarning, DeprecationWarning):
"""Param DeprecationWarning
"""
Param DeprecationWarning

Ignored by default except when triggered by code in __main__
"""


class ParamFutureWarning(ParamWarning, FutureWarning):
"""Param FutureWarning
"""
Param FutureWarning

Always displayed.
"""
Expand All @@ -80,7 +83,8 @@ def inner(*args, **kwargs):


def _deprecate_positional_args(func):
"""Internal decorator for methods that issues warnings for positional arguments
"""
Internal decorator for methods that issues warnings for positional arguments
Using the keyword-only argument syntax in pep 3102, arguments after the
``*`` will issue a warning when passed as a positional argument.
Adapted from scikit-learn
Expand Down Expand Up @@ -122,7 +126,7 @@ def inner(*args, **kwargs):

# Copy of Python 3.2 reprlib's recursive_repr but allowing extra arguments
def _recursive_repr(fillvalue='...'):
'Decorator to make a repr function return fillvalue for a recursive call'
"""Decorator to make a repr function return fillvalue for a recursive call"""

def decorating_function(user_function):
repr_running = set()
Expand Down Expand Up @@ -273,6 +277,7 @@ def flatten(line):
Returns
-------
flattened : generator

"""
for element in line:
if any(isinstance(element, tp) for tp in (list, tuple, dict)):
Expand Down Expand Up @@ -572,7 +577,8 @@ def _to_datetime(x):

@contextmanager
def exceptions_summarized():
"""Useful utility for writing docs that need to show expected errors.
"""
Useful utility for writing docs that need to show expected errors.
Shows exception only, concisely, without a traceback.
"""
try:
Expand Down Expand Up @@ -622,7 +628,8 @@ def __iter__(cls):
def gen_types(gen_func):
"""
Decorator which takes a generator function which yields difference types
make it so it can be called with isinstance and issubclass."""
make it so it can be called with isinstance and issubclass.
"""
if not inspect.isgeneratorfunction(gen_func):
msg = "gen_types decorator can only be applied to generator"
raise TypeError(msg)
Expand Down
4 changes: 3 additions & 1 deletion param/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def depends(
def depends(
func: CallableT, /, *dependencies: Dependency, watch: bool = False, on_init: bool = False, **kw: Parameter
) -> Callable[[CallableT], DependsFunc[CallableT]]:
"""Annotates a function or Parameterized method to express its dependencies.
"""
Annotates a function or Parameterized method to express its dependencies.

The specified dependencies can be either be Parameter instances or if a
method is supplied they can be defined as strings referring to Parameters
Expand All @@ -57,6 +58,7 @@ def depends(
on_init : bool, optional
Whether to invoke the function/method when the instance is created,
by default False

"""
dependencies, kw = (
tuple(transform_reference(arg) for arg in dependencies),
Expand Down
5 changes: 1 addition & 4 deletions param/ipython.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def get_param_info(self, obj, include_super=True):
and the dictionary of parameter values. If include_super is
True, parameters are also collected from the super classes.
"""

params = dict(obj.param.objects('existing'))
if isinstance(obj,type):
changed = []
Expand All @@ -86,7 +85,6 @@ def param_docstrings(self, info, max_col_len=100, only_changed=False):
docstrings in a clean format (alternating red and blue for
readability).
"""

(params, val_dict, changed) = info
contents = []
displayed_params = []
Expand Down Expand Up @@ -147,7 +145,6 @@ def _build_table(self, info, order, max_col_len=40, only_changed=False):
Collect the information about parameters needed to build a
properly formatted table and then tabulate it.
"""

info_list, bounds_dict = [], {}
(params, val_dict, changed) = info
col_widths = {k:0 for k in order}
Expand Down Expand Up @@ -209,7 +206,6 @@ def _tabulate(self, info_list, col_widths, changed, order, bounds_dict):
order: The order of the table columns
bound_dict: Dictionary of appropriately formatted bounds
"""

contents, tail = [], []
column_set = {k for _, row in info_list for k in row}
columns = [col for col in order if col in column_set]
Expand Down Expand Up @@ -316,6 +312,7 @@ class ParamMagics(Magics):
Implements the %params line magic used to inspect the parameters
of a parameterized class or object.
"""

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.param_pager = ParamPager()
Expand Down
Loading
Loading