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 docstring linting and fix issues #979

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion doc/user_guide/ParameterizedFunctions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"from param import Parameter, ParameterizedFunction, ParamOverrides\n",
"\n",
"class multiply(ParameterizedFunction):\n",
" \"Function to multiply two arguments.\"\n",
" \"\"\"Function to multiply two arguments.\"\"\"\n",
MarcSkovMadsen marked this conversation as resolved.
Show resolved Hide resolved
"\n",
" left = Parameter(2, doc=\"Left-hand-side argument\")\n",
" right = Parameter(4, doc=\"Right-hand-side argument\")\n",
Expand Down
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
5 changes: 3 additions & 2 deletions param/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,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 @@ -631,7 +631,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
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