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

Remove a bunch of unused pylint supressions #243

Merged
merged 2 commits into from
Jul 8, 2024
Merged
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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.8", "3.9", "3.x", "pypy3.8"]
python-version: ["3.8", "3.9", "3.x", "pypy3.9"]
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
Expand Down
37 changes: 15 additions & 22 deletions pytools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# pylint: disable=too-many-lines
# (Yes, it has a point!)


__copyright__ = """
Copyright (C) 2009-2013 Andreas Kloeckner
Copyright (C) 2020 Matt Wala
Expand Down Expand Up @@ -584,7 +580,7 @@ def copy(self):

def __contains__(self, key):
try:
self[key] # pylint: disable=pointless-statement
self[key]
return True
except KeyError:
return False
Expand Down Expand Up @@ -707,7 +703,7 @@ def memoize(*args: F, **kwargs: Any) -> F:
default_key_func: Optional[Callable[..., Any]]

if use_kw:
def default_key_func(*inner_args, **inner_kwargs): # pylint:disable=function-redefined
def default_key_func(*inner_args, **inner_kwargs):
return inner_args, frozenset(inner_kwargs.items())
else:
default_key_func = None
Expand All @@ -724,15 +720,15 @@ def _decorator(func):
def wrapper(*args, **kwargs):
key = key_func(*args, **kwargs)
try:
return func._memoize_dic[key] # pylint: disable=protected-access
return func._memoize_dic[key]
except AttributeError:
# _memoize_dic doesn't exist yet.
result = func(*args, **kwargs)
func._memoize_dic = {key: result} # pylint: disable=protected-access
func._memoize_dic = {key: result}
return result
except KeyError:
result = func(*args, **kwargs)
func._memoize_dic[key] = result # pylint: disable=protected-access
func._memoize_dic[key] = result
return result

from functools import update_wrapper
Expand All @@ -743,15 +739,15 @@ def wrapper(*args, **kwargs):
def _decorator(func):
def wrapper(*args):
try:
return func._memoize_dic[args] # pylint: disable=protected-access
return func._memoize_dic[args]
except AttributeError:
# _memoize_dic doesn't exist yet.
result = func(*args)
func._memoize_dic = {args: result} # pylint:disable=protected-access
func._memoize_dic = {args: result}
return result
except KeyError:
result = func(*args)
func._memoize_dic[args] = result # pylint: disable=protected-access
func._memoize_dic[args] = result
return result

from functools import update_wrapper
Expand Down Expand Up @@ -1808,7 +1804,7 @@ def remove_columns(i, row):

# {{{ histogram formatting

def string_histogram( # pylint: disable=too-many-arguments,too-many-locals
def string_histogram(
iterable, min_value=None, max_value=None,
bin_count=20, width=70, bin_starts=None, use_unicode=True):
if bin_starts is None:
Expand Down Expand Up @@ -1969,7 +1965,6 @@ def validate(self, setup):

class StderrToStdout:
def __enter__(self):
# pylint: disable=attribute-defined-outside-init
self.stderr_backup = sys.stderr
sys.stderr = sys.stdout

Expand Down Expand Up @@ -2079,7 +2074,7 @@ def invoke_editor(s, filename="edit.txt", descr="the file"):

# {{{ progress bars

class ProgressBar: # pylint: disable=too-many-instance-attributes
class ProgressBar:
"""
.. automethod:: draw
.. automethod:: progress
Expand Down Expand Up @@ -2353,8 +2348,6 @@ def __init__(self, min_rec_limit):
self.min_rec_limit = min_rec_limit

def __enter__(self):
# pylint: disable=attribute-defined-outside-init

self.prev_recursion_limit = sys.getrecursionlimit()
new_limit = max(self.prev_recursion_limit, self.min_rec_limit)
sys.setrecursionlimit(new_limit)
Expand Down Expand Up @@ -2405,7 +2398,7 @@ def download_from_web_if_not_present(url, local_name=None):

# {{{ find git revisions

def find_git_revision(tree_root): # pylint: disable=too-many-locals
def find_git_revision(tree_root):
# Keep this routine self-contained so that it can be copy-pasted into
# setup.py.

Expand Down Expand Up @@ -2545,7 +2538,7 @@ def _log_start_if_long(logger, sleep_duration, done_indicator,
sleep_duration)


class ProcessLogger: # pylint: disable=too-many-instance-attributes
class ProcessLogger:
"""Logs the completion time of a (presumably) lengthy process to :mod:`logging`.
Only uses a high log level if the process took perceptible time.

Expand All @@ -2557,7 +2550,7 @@ class ProcessLogger: # pylint: disable=too-many-instance-attributes

default_noisy_level = logging.INFO

def __init__( # pylint: disable=too-many-arguments
def __init__(
self, logger, description,
silent_level=None, noisy_level=None, long_threshold_seconds=None):
self.logger = logger
Expand Down Expand Up @@ -2616,7 +2609,7 @@ def __init__( # pylint: disable=too-many-arguments

self.timer = ProcessTimer()

def done( # pylint: disable=keyword-arg-before-vararg
def done(
self, extra_msg=None, *extra_fmt_args):
self.timer.done()
self._done_indicator[0] = True
Expand Down Expand Up @@ -2747,7 +2740,7 @@ def resolve_name(name):
if sys.version_info >= (3, 9):
# use the official version
import pkgutil
return pkgutil.resolve_name(name) # pylint: disable=no-member
return pkgutil.resolve_name(name)

import importlib

Expand Down
4 changes: 2 additions & 2 deletions pytools/datatable.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def join(self, column: str, other_column: str, other_table: "DataTable",

Assumes both tables are sorted ascendingly by the column
by which they are joined.
""" # pylint:disable=too-many-locals,too-many-branches
"""

def without(indexable: Tuple[str, ...], idx: int) -> Tuple[str, ...]:
return indexable[:idx] + indexable[idx+1:]
Expand Down Expand Up @@ -243,7 +243,7 @@ def without(indexable: Tuple[str, ...], idx: int) -> Tuple[str, ...]:
if outer:
this_batch = [(None,) * len(self.column_names)]

if run_other and not other_over: # pylint: disable=used-before-assignment
if run_other and not other_over:
key = other_key
while other_row[other_key_idx] == other_key:
other_batch.append(other_row)
Expand Down
4 changes: 2 additions & 2 deletions pytools/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class RefDebugQuit(Exception): # noqa: N818
pass


def refdebug(obj, top_level=True, exclude=()): # pylint:disable=too-many-locals,too-many-branches,too-many-statements
def refdebug(obj, top_level=True, exclude=()):
from types import FrameType

def is_excluded(o):
Expand Down Expand Up @@ -154,7 +154,7 @@ def setup_readline():
try:
readline.read_history_file(hist_filename)
except Exception: # pylint:disable=broad-except
# http://docs.python.org/3/howto/pyporting.html#capturing-the-currently-raised-exception # noqa: E501 pylint:disable=line-too-long
# http://docs.python.org/3/howto/pyporting.html#capturing-the-currently-raised-exception # noqa: E501
import sys
e = sys.exc_info()[1]

Expand Down
3 changes: 1 addition & 2 deletions pytools/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def reverse_graph(graph: GraphT[NodeT]) -> GraphT[NodeT]:

# {{{ a_star

def a_star( # pylint: disable=too-many-locals
def a_star(
initial_state: NodeT, goal_state: NodeT, neighbor_map: GraphT[NodeT],
estimate_remaining_cost: Optional[Callable[[NodeT], float]] = None,
get_step_cost: Callable[[Any, NodeT], float] = lambda x, y: 1
Expand All @@ -129,7 +129,6 @@ def a_star( # pylint: disable=too-many-locals
from heapq import heappop, heappush

if estimate_remaining_cost is None:
# pylint: disable=function-redefined
def estimate_remaining_cost(x: NodeT) -> float:
if x != goal_state:
return 1
Expand Down
3 changes: 1 addition & 2 deletions pytools/persistent_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ def rec(self, key_hash: Hash, key: Any) -> Hash:

if not isinstance(key, type):
try:
# pylint:disable=protected-access
object.__setattr__(key, "_pytools_persistent_hash_digest", digest)
except AttributeError:
pass
Expand Down Expand Up @@ -544,7 +543,7 @@ def _collision_check(self, key: K, stored_key: K) -> None:

# This is here so we can step through equality comparison to
# see what is actually non-equal.
stored_key == key # pylint:disable=pointless-statement # noqa: B015
stored_key == key # noqa: B015
raise NoSuchEntryCollisionError(key)

def _exec_sql(self, *args: Any) -> sqlite3.Cursor:
Expand Down
4 changes: 2 additions & 2 deletions pytools/prefork.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def _fork_server(sock):
sock.close()

import os
os._exit(0) # pylint:disable=protected-access
os._exit(0)


class IndirectForker:
Expand Down Expand Up @@ -191,7 +191,7 @@ def waitall(self):


def enable_prefork():
global forker # pylint:disable=global-statement
global forker

if isinstance(forker, IndirectForker):
return
Expand Down
2 changes: 1 addition & 1 deletion pytools/spatial_btree.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def insert_into_subdivision(element, bbox):
# No subdivisions yet.
if len(self.elements) > self.max_elements_per_box:
# Too many elements. Need to subdivide.
self.all_buckets = [] # pylint:disable=attribute-defined-outside-init
self.all_buckets = []
self.buckets = make_buckets(
self.bottom_left, self.top_right,
self.all_buckets,
Expand Down
6 changes: 2 additions & 4 deletions pytools/test/test_pytools.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def f(self):
sc.f()
assert sc.run_count == 1

sc.f.clear_cache(sc) # pylint: disable=no-member
sc.f.clear_cache(sc)


def test_keyed_memoize_method_with_uncached():
Expand All @@ -73,7 +73,7 @@ def f(self, x, y, z):
sc.f(18, 19, z=20)
assert sc.run_count == 2

sc.f.clear_cache(sc) # pylint: disable=no-member
sc.f.clear_cache(sc)


def test_memoize_in():
Expand Down Expand Up @@ -190,7 +190,6 @@ def double_value(self):
c0 = FrozenDataclass(10)
assert c0.double_value() == 20

# pylint: disable=no-member
c0.double_value.clear_cache(c0) # type: ignore[attr-defined]

# }}}
Expand All @@ -213,7 +212,6 @@ def double_value(self):
c1 = FrozenClass(10)
assert c1.double_value() == 20

# pylint: disable=no-member
c1.double_value.clear_cache(c1) # type: ignore[attr-defined]

# }}}
Expand Down
Loading