Skip to content

Commit 4b0fc23

Browse files
committed
Update pylint and fix code
1 parent 99f0ca2 commit 4b0fc23

File tree

4 files changed

+61
-45
lines changed

4 files changed

+61
-45
lines changed

.pylintrc

Lines changed: 53 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# run arbitrary code.
66
extension-pkg-whitelist=
77

8+
# Specify a score threshold to be exceeded before program exits with error.
9+
fail-under=10.0
10+
811
# Add files or directories to the blacklist. They should be base names, not
912
# paths.
1013
ignore=CVS
@@ -26,16 +29,13 @@ jobs=1
2629
# complex, nested conditions.
2730
limit-inference-results=100
2831

29-
# List of plugins (as comma separated values of python modules names) to load,
32+
# List of plugins (as comma separated values of python module names) to load,
3033
# usually to register additional checkers.
3134
load-plugins=
3235

3336
# Pickle collected data for later comparisons.
3437
persistent=yes
3538

36-
# Specify a configuration file.
37-
#rcfile=
38-
3939
# When enabled, pylint would attempt to guess common misconfiguration and emit
4040
# user-friendly hints instead of false-positive error messages.
4141
suggestion-mode=yes
@@ -139,12 +139,10 @@ disable=print-statement,
139139
deprecated-sys-function,
140140
exception-escape,
141141
comprehension-escape,
142-
no-else-return,
143142
no-member,
144-
useless-object-inheritance,
143+
no-else-return,
144+
duplicate-code,
145145
inconsistent-return-statements,
146-
ungrouped-imports,
147-
not-callable,
148146

149147
# Enable the message, report, category or checker with the given id(s). You can
150148
# either give multiple identifier separated by comma (,) or put this option
@@ -155,11 +153,11 @@ enable=c-extension-no-member
155153

156154
[REPORTS]
157155

158-
# Python expression which should return a note less than 10 (10 is the highest
159-
# note). You have access to the variables errors warning, statement which
160-
# respectively contain the number of errors / warnings messages and the total
161-
# number of statements analyzed. This is used by the global evaluation report
162-
# (RP0004).
156+
# Python expression which should return a score less than or equal to 10. You
157+
# have access to the variables 'error', 'warning', 'refactor', and 'convention'
158+
# which contain the number of messages in each category, as well as 'statement'
159+
# which is the total number of statements analyzed. This score is used by the
160+
# global evaluation report (RP0004).
163161
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
164162

165163
# Template used to display messages. This is a python new-style format string
@@ -181,7 +179,7 @@ score=yes
181179
[REFACTORING]
182180

183181
# Maximum number of nested blocks for function / method body
184-
max-nested-blocks=6
182+
max-nested-blocks=5
185183

186184
# Complete name of functions that never returns. When checking for
187185
# inconsistent-return-statements if a never returning function is called then
@@ -192,8 +190,8 @@ never-returning-functions=sys.exit
192190

193191
[LOGGING]
194192

195-
# Format style used to check logging format string. `old` means using %
196-
# formatting, while `new` is for `{}` formatting.
193+
# The type of string formatting that logging methods do. `old` means using %
194+
# formatting, `new` is for `{}` formatting.
197195
logging-format-style=old
198196

199197
# Logging modules to check that the string format arguments are in logging
@@ -206,18 +204,18 @@ logging-modules=logging
206204
# Limits count of emitted suggestions for spelling mistakes.
207205
max-spelling-suggestions=4
208206

209-
# Spelling dictionary name. Available dictionaries: none. To make it working
210-
# install python-enchant package..
207+
# Spelling dictionary name. Available dictionaries: none. To make it work,
208+
# install the python-enchant package.
211209
spelling-dict=
212210

213211
# List of comma separated words that should not be checked.
214212
spelling-ignore-words=
215213

216-
# A path to a file that contains private dictionary; one word per line.
214+
# A path to a file that contains the private dictionary; one word per line.
217215
spelling-private-dict-file=
218216

219-
# Tells whether to store unknown words to indicated private dictionary in
220-
# --spelling-private-dict-file option instead of raising a message.
217+
# Tells whether to store unknown words to the private dictionary (see the
218+
# --spelling-private-dict-file option) instead of raising a message.
221219
spelling-store-unknown-words=no
222220

223221

@@ -228,6 +226,9 @@ notes=FIXME,
228226
XXX,
229227
TODO
230228

229+
# Regular expression of note tags to take in consideration.
230+
#notes-rgx=
231+
231232

232233
[TYPECHECK]
233234

@@ -264,7 +265,7 @@ ignored-classes=optparse.Values,thread._local,_thread._local
264265

265266
# List of module names for which member attributes should not be checked
266267
# (useful for modules/projects where namespaces are manipulated during runtime
267-
# and thus existing member attributes cannot be deduced by static analysis. It
268+
# and thus existing member attributes cannot be deduced by static analysis). It
268269
# supports qualified module names, as well as Unix pattern matching.
269270
ignored-modules=
270271

@@ -280,6 +281,9 @@ missing-member-hint-distance=1
280281
# showing a hint for a missing member.
281282
missing-member-max-choices=1
282283

284+
# List of decorators that change the signature of a decorated function.
285+
signature-mutators=
286+
283287

284288
[VARIABLES]
285289

@@ -330,14 +334,7 @@ indent-string=' '
330334
max-line-length=100
331335

332336
# Maximum number of lines in a module.
333-
max-module-lines=2500
334-
335-
# List of optional constructs for which whitespace checking is disabled. `dict-
336-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
337-
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
338-
# `empty-line` allows space-only lines.
339-
no-space-check=trailing-comma,
340-
dict-separator
337+
max-module-lines=3000
341338

342339
# Allow the body of a class to be on the same line as the declaration if body
343340
# contains single statement.
@@ -357,10 +354,10 @@ ignore-comments=yes
357354
ignore-docstrings=yes
358355

359356
# Ignore imports when computing similarities.
360-
ignore-imports=no
357+
ignore-imports=yes
361358

362359
# Minimum lines number of a similarity.
363-
min-similarity-lines=9
360+
min-similarity-lines=4
364361

365362

366363
[BASIC]
@@ -387,6 +384,10 @@ bad-names=foo,
387384
tutu,
388385
tata
389386

387+
# Bad variable names regexes, separated by a comma. If names match any regex,
388+
# they will always be refused
389+
bad-names-rgxs=
390+
390391
# Naming style matching correct class attribute names.
391392
class-attribute-naming-style=any
392393

@@ -427,6 +428,10 @@ good-names=i,
427428
Run,
428429
_
429430

431+
# Good variable names regexes, separated by a comma. If names match any regex,
432+
# they will always be accepted
433+
good-names-rgxs=
434+
430435
# Include a hint for the correct naming format with invalid-name.
431436
include-naming-hint=no
432437

@@ -474,14 +479,21 @@ variable-naming-style=snake_case
474479

475480
[STRING]
476481

477-
# This flag controls whether the implicit-str-concat-in-sequence should
478-
# generate a warning on implicit string concatenation in sequences defined over
479-
# several lines.
482+
# This flag controls whether inconsistent-quotes generates a warning when the
483+
# character used as a quote delimiter is used inconsistently within a module.
484+
check-quote-consistency=no
485+
486+
# This flag controls whether the implicit-str-concat should generate a warning
487+
# on implicit string concatenation in sequences defined over several lines.
480488
check-str-concat-over-line-jumps=no
481489

482490

483491
[IMPORTS]
484492

493+
# List of modules that can be imported at any level, not just the top level
494+
# one.
495+
allow-any-import-level=
496+
485497
# Allow wildcard imports from modules that define __all__.
486498
allow-wildcard-with-all=no
487499

@@ -512,13 +524,17 @@ known-standard-library=
512524
# Force import order to recognize a module as part of a third party library.
513525
known-third-party=enchant
514526

527+
# Couples of modules and preferred modules, separated by a comma.
528+
preferred-modules=
529+
515530

516531
[CLASSES]
517532

518533
# List of method names used to declare (i.e. assign) instance attributes.
519534
defining-attr-methods=__init__,
520535
__new__,
521-
setUp
536+
setUp,
537+
__post_init__
522538

523539
# List of member names, which should be excluded from the protected access
524540
# warning.
@@ -543,7 +559,7 @@ max-args=8
543559
# Maximum number of attributes for a class (see R0902).
544560
max-attributes=8
545561

546-
# Maximum number of boolean expressions in an if statement.
562+
# Maximum number of boolean expressions in an if statement (see R0916).
547563
max-bool-expr=5
548564

549565
# Maximum number of branch for function / method body.

diskcache/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def __repr__(self):
109109
}
110110

111111

112-
class Disk(object):
112+
class Disk:
113113
"Cache key and value serialization for SQLite database and files."
114114

115115
def __init__(self, directory, min_file_size=0, pickle_protocol=0):
@@ -418,7 +418,7 @@ def args_to_key(base, args, kwargs, typed):
418418
return key
419419

420420

421-
class Cache(object):
421+
class Cache:
422422
"Disk and file backed cache."
423423

424424
def __init__(self, directory=None, timeout=60, disk=Disk, **settings):
@@ -2138,7 +2138,7 @@ def cull(self, retry=False):
21382138
select_policy = EVICTION_POLICY[self.eviction_policy]['cull']
21392139

21402140
if select_policy is None:
2141-
return
2141+
return 0
21422142

21432143
select_filename = select_policy.format(fields='filename', now=now)
21442144

diskcache/fanout.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from .persistent import Deque, Index
1414

1515

16-
class FanoutCache(object):
16+
class FanoutCache:
1717
"Cache that shards keys and values."
1818

1919
def __init__(

diskcache/recipes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .core import ENOVAL, args_to_key, full_name
1313

1414

15-
class Averager(object):
15+
class Averager:
1616
"""Recipe for calculating a running average.
1717
1818
Sometimes known as "online statistics," the running average maintains the
@@ -63,7 +63,7 @@ def pop(self):
6363
return None if count == 0 else total / count
6464

6565

66-
class Lock(object):
66+
class Lock:
6767
"""Recipe for cross-process and cross-thread lock.
6868
6969
>>> import diskcache
@@ -111,7 +111,7 @@ def __exit__(self, *exc_info):
111111
self.release()
112112

113113

114-
class RLock(object):
114+
class RLock:
115115
"""Recipe for cross-process and cross-thread re-entrant lock.
116116
117117
>>> import diskcache
@@ -179,7 +179,7 @@ def __exit__(self, *exc_info):
179179
self.release()
180180

181181

182-
class BoundedSemaphore(object):
182+
class BoundedSemaphore:
183183
"""Recipe for cross-process and cross-thread bounded semaphore.
184184
185185
>>> import diskcache

0 commit comments

Comments
 (0)