Skip to content

Commit eb658fc

Browse files
committed
Some pylint updates
1 parent cac3850 commit eb658fc

2 files changed

Lines changed: 16 additions & 53 deletions

File tree

.pylintrc

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ confidence=
5959
#
6060
# Kubeflow disables string-interpolation because we are starting to use f
6161
# style strings
62-
disable=import-error, bad-continuation, protected-access, redefined-outer-name, E5110
62+
disable=import-error, protected-access, redefined-outer-name
6363

6464

6565
[REPORTS]
@@ -69,11 +69,6 @@ disable=import-error, bad-continuation, protected-access, redefined-outer-name,
6969
# mypackage.mymodule.MyReporterClass.
7070
output-format=parseable
7171

72-
# Put messages in a separate file for each module / package specified on the
73-
# command line instead of printing them on stdout. Reports (if any) will be
74-
# written in a file name "pylint_global.[txt|html]". This option is deprecated
75-
# and it will be removed in Pylint 2.0.
76-
files-output=no
7772

7873
# Tells whether to display a full report or only the messages
7974
reports=no
@@ -123,63 +118,34 @@ property-classes=abc.abstractproperty
123118
# Regular expression matching correct function names
124119
function-rgx=([a-z][a-z0-9_]{2,25})|(_[a-zA-Z9-9_]{2,25})$
125120

126-
# Naming hint for function names
127-
function-name-hint=[a-z_][a-z0-9_]{2,25}$
128-
129121
# Regular expression matching correct variable names
130122
variable-rgx=[A-Za-z_]([a-z0-9_][A-Za-z0-9_]{0,15})?$
131123

132-
# Naming hint for variable names
133-
variable-name-hint=[A-Za-z_]([a-z0-9_][A-Za-z0-9_]{0,25})?$
134-
135124
# Regular expression matching correct constant names
136125
const-rgx=(([A-Z_][A-Za-z0-9_]*)|(__.*__))$
137126

138-
# Naming hint for constant names
139-
const-name-hint=(([A-Z_][A-Za-z0-9_]*)|(__.*__))$
140-
141127
# Regular expression matching correct attribute names
142128
attr-rgx=[A-Za-z_]([a-z0-9_][A-Za-z0-9_]{0,25})?$
143129

144-
# Naming hint for attribute names
145-
attr-name-hint=[A-Za-z_]([a-z0-9_][A-Za-z0-9_]{0,15})?$
146-
147130
# Regular expression matching correct argument names
148131
argument-rgx=[A-Za-z_]([a-z0-9_][A-Za-z0-9_]{0,25})?$
149132

150-
# Naming hint for argument names
151-
argument-name-hint=[A-Za-z_]([a-z0-9_][A-Za-z0-9_]{0,25})?$
152133

153134
# Regular expression matching correct class attribute names
154135
class-attribute-rgx=([A-Za-z_]([a-z0-9_][A-Za-z0-9_]{0,25})?|(__.*__))$
155136

156-
# Naming hint for class attribute names
157-
class-attribute-name-hint=([A-Za-z_]([a-z0-9_][A-Za-z0-9_]{0,25})?|(__.*__))$
158-
159137
# Regular expression matching correct inline iteration names
160138
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
161139

162-
# Naming hint for inline iteration names
163-
inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
164-
165140
# Regular expression matching correct class names
166141
class-rgx=[A-Z_][a-zA-Z0-9_]+$
167142

168-
# Naming hint for class names
169-
class-name-hint=[A-Z_][a-zA-Z0-9_]+$
170-
171143
# Regular expression matching correct module names
172144
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
173145

174-
# Naming hint for module names
175-
module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
176-
177146
# Regular expression matching correct method names
178147
method-rgx=[a-z_][a-z0-9_]{2,25}$
179148

180-
# Naming hint for method names
181-
method-name-hint=[a-z_][a-z0-9_]{2,25}$
182-
183149
# Regular expression which should only match function or class names that do
184150
# not require a docstring.
185151
no-docstring-rgx=^_
@@ -235,12 +201,6 @@ ignore-long-lines=^\s*(# )?<?https?://\S+>?$
235201
# else.
236202
single-line-if-stmt=yes
237203

238-
# List of optional constructs for which whitespace checking is disabled. `dict-
239-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
240-
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
241-
# `empty-line` allows space-only lines.
242-
no-space-check=trailing-comma,dict-separator
243-
244204
# Maximum number of lines in a module
245205
max-module-lines=2000
246206

Stoner/core/methods.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from statsmodels.stats.weightstats import DescrStatsW
1313

1414
from ..compat import _pattern_type, int_types, str2bytes
15-
from ..tools import all_type, format_error, isiterable, operator
15+
from ..tools import all_type, format_error, isiterable, operator, make_Class
1616
from ..tools.file import HDFFileManager, best_saver, file_dialog
1717
from ..tools.widgets import RangeSelect
1818
from .array import DataArray
@@ -401,7 +401,10 @@ def section(datafile, x=None, y=None, z=None, r=None, accuracy=0.0, **kwargs):
401401
if z is not None:
402402
tmp.data = tmp.search(zcol, z, accuracy=accuracy)
403403
if r is not None:
404-
func = lambda x, row: r(row[xcol], row[ycol], row[zcol])
404+
405+
def func(_, row):
406+
return r(row[xcol], row[ycol], row[zcol])
407+
405408
tmp.data = tmp.search(0, func, accuracy=accuracy)
406409

407410
if kwargs: # Fallback to working with select if nothing else.
@@ -598,7 +601,7 @@ def split(datafile, *args, final="files"):
598601
There has been a change in the arguments for the split function from version 0.8 of the Stoner
599602
Package.
600603
"""
601-
from Stoner import DataFolder
604+
DataFolder = make_Class("DataFolder", None)
602605

603606
if not args:
604607
xcol = datafile.setas._get_cols("xcol")
@@ -753,7 +756,7 @@ def add_column(datafile, column_data, header=None, index=None, func_args=None, r
753756
case (_, _):
754757
(dr, dc) = datafile.data.shape
755758
case _ if not datafile.data.shape:
756-
datafile.data = np.array([list()])
759+
datafile.data = np.array([[]])
757760
(dr, dc) = (0, 0)
758761
case _:
759762
raise ValueError("Data should be 1 or 2 dimensional")
@@ -841,8 +844,7 @@ def columns(datafile, not_masked=False, reset=False):
841844
continue
842845
if reset:
843846
return
844-
else:
845-
yield datafile.column(ix)
847+
yield datafile.column(ix)
846848

847849

848850
def del_column(datafile, col=None, duplicates=False):
@@ -903,11 +905,11 @@ def del_column(datafile, col=None, duplicates=False):
903905
datafile.column_headers = ch
904906
elif isiterable(col) and all_type(col, bool): # If col is an iterable of booleans then we index by that
905907
col = ~np.array(col)
908+
col_hdrs = np.array(datafile.column_headers)[col]
906909
new_setas = np.array(datafile.setas)[col]
907-
new_column_headers = np.array(datafile.column_headers)[col]
908910
datafile.data = datafile.data[:, col]
909911
datafile.setas = new_setas
910-
datafile.column_headers = new_column_headers
912+
datafile.column_headers = col_hdrs
911913
else: # Otherwise find individual columns
912914
c = datafile.find_col(col)
913915
ch = datafile.column_headers
@@ -1011,7 +1013,7 @@ def del_rows(datafile, col=None, val=None, invert=False):
10111013
return datafile
10121014

10131015

1014-
def dir(datafile, pattern=None):
1016+
def dir(datafile, pattern=None): # pylint: disable=redefined-builtin
10151017
"""Return a list of keys in the metadata, filtering with a regular expression if necessary.
10161018
10171019
Args:
@@ -1156,8 +1158,7 @@ def rows(datafile, not_masked=False, reset=False):
11561158
continue
11571159
if reset:
11581160
return
1159-
else:
1160-
yield row
1161+
yield row
11611162

11621163

11631164
def save(datafile, filename=None, as_loaded=None, filetype=False):
@@ -1262,7 +1263,9 @@ def to_pandas(datafile):
12621263
return df
12631264

12641265

1265-
def format(datafile, key, mode="float", units=None, prefix=None, latex=False, fmt=None, escape=False):
1266+
def format( # pylint: disable=redefined-builtin
1267+
datafile, key, mode="float", units=None, prefix=None, latex=False, fmt=None, escape=False
1268+
):
12661269
r"""Return the contents of key pretty formatted using :py:func:`format_error`.
12671270
12681271
Args:

0 commit comments

Comments
 (0)