Skip to content

Commit

Permalink
Enable ruff PGH error class.
Browse files Browse the repository at this point in the history
  • Loading branch information
fschulze committed Aug 31, 2023
1 parent 45ce86b commit 09f6747
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 32 deletions.
4 changes: 2 additions & 2 deletions client/testing/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import json
import time

from .reqmock import reqmock # noqa
from .reqmock import reqmock # noqa: F401 (definition of reqmock fixture)
from devpi.main import Hub, get_pluginmanager, initmain, parse_args
from devpi_common.url import URL

Expand Down Expand Up @@ -689,7 +689,7 @@ def mkhub(arglist):


@pytest.fixture
def mock_http_api(monkeypatch, reqmock): # noqa
def mock_http_api(monkeypatch, reqmock): # noqa: F811 (reqmock)
""" mock out all Hub.http_api calls and return an object
offering 'set' and 'add' to fake replies. """
from devpi import main
Expand Down
4 changes: 2 additions & 2 deletions client/testing/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,9 @@ def new_user_id(gen, mapp):
"""
user_id = "tmp_%s_%s" % (gen.user(), str(time.time()))
yield user_id
try:
try: # noqa: SIM105
mapp.delete_user(user=user_id, code=201)
except: # noqa
except: # noqa: E722
# We need a bare except here, because there are exceptions from
# pytest and other places which don't derive from Exception and
# listing them all would be long and not future proof
Expand Down
2 changes: 1 addition & 1 deletion client/testing/test_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def test_main_example_with_basic_auth(self, initproj, devpi, out_devpi):

def test_no_post(self, out_devpi, create_and_upload, monkeypatch):
def post(*args, **kwargs):
0 / 0
0 / 0 # noqa: B018

create_and_upload("exa-1.0", filedefs={
"tox.ini": """
Expand Down
2 changes: 1 addition & 1 deletion common/devpi_common/types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import absolute_import, unicode_literals
from lazy import lazy as cached_property # noqa
from lazy import lazy as cached_property # noqa: F401 must be importable
from types import FunctionType
import hashlib
import operator
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[tool.ruff]
select = [
"B", "COM", "DTZ", "E", "ERA", "EXE", "F",
"ICN", "ISC", "PIE", "PLC", "PLE", "PLR", "PLW",
"ICN", "ISC", "PGH", "PIE", "PLC", "PLE", "PLR", "PLW",
"RUF", "SIM", "T10", "TID", "TRY", "W", "YTT",
]
ignore = [
"B007", # maybe cleanup later
"B008", # cleanup later
"B018", # cleanup later
"B904", # maybe cleanup later
"COM812", # cleanup later
"DTZ001", # cleanup soon
"E501",
"E741",
"ERA001", # cleanup soon
"PGH003", # cleanup later
"PIE804", # cleanup later
"PIE808", # maybe cleanup later
"PLC1901", # maybe cleanup later
Expand Down
2 changes: 1 addition & 1 deletion server/devpi_server/keyfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ def __init__(self, keyfs, at_serial=None, write=False):
self.write = write
if self.write:
# open connection immediately
self.conn
self.conn # noqa: B018
if at_serial is None:
at_serial = self.conn.last_changelog_serial
self.at_serial = at_serial
Expand Down
2 changes: 1 addition & 1 deletion server/devpi_server/sizeof.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ def gettotalsizeof(
return result
except TypeError:
# PyPy doesn't implement getsizeof, use dumplen as estimate
from .fileutil import dumplen as gettotalsizeof # type: ignore # noqa
from .fileutil import dumplen as gettotalsizeof # type: ignore # noqa: F401
3 changes: 2 additions & 1 deletion server/devpi_server/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,8 @@ def simple_list_project(self):
abort(request, 502, e.msg)

if not result:
self.request.context.verified_project # access will trigger 404 if not found
# access of verified_project will trigger 404 if not found
self.request.context.verified_project # noqa: B018

if requested_by_installer:
# we don't need the extra stuff on the simple page for pip
Expand Down
2 changes: 1 addition & 1 deletion server/test_devpi_server/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import sys
import time
from .functional import MappMixin
from .reqmock import reqmock, patch_reqsessionmock # noqa
from .reqmock import reqmock, patch_reqsessionmock # noqa: F401 (definition of fixtures)
from bs4 import BeautifulSoup
from contextlib import closing
from devpi_server import mirror
Expand Down
12 changes: 6 additions & 6 deletions server/test_devpi_server/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_secret_complexity(self, tmpdir):
# and use it
config = make_config(["devpi-server", "--secretfile=%s" % p])
with pytest.raises(Fatal, match="at least 32 characters"):
config.basesecret
config.basesecret # noqa: B018
# create a secret file which is too repetitive
p = configdir.join("secret")
secret = b"12345" * 7
Expand All @@ -127,7 +127,7 @@ def test_secret_complexity(self, tmpdir):
# and use it
config = make_config(["devpi-server", "--secretfile=%s" % p])
with pytest.raises(Fatal, match="less repetition"):
config.basesecret
config.basesecret # noqa: B018

@pytest.mark.skipif("sys.platform == 'win32'")
def test_secretfile_permissions(self, tmpdir):
Expand All @@ -140,16 +140,16 @@ def test_secretfile_permissions(self, tmpdir):
p.chmod(0o677)
config = make_config(["devpi-server", "--secretfile=%s" % p])
with pytest.raises(Fatal, match="file is world accessible"):
config.basesecret
config.basesecret # noqa: B018
p.chmod(0o670)
with pytest.raises(Fatal, match="file is group accessible"):
config.basesecret
config.basesecret # noqa: B018
p.chmod(0o600)
with pytest.raises(Fatal, match="folder of the given secret file is group writable"):
config.basesecret
config.basesecret # noqa: B018
configdir.chmod(0o707)
with pytest.raises(Fatal, match="folder of the given secret file is world writable"):
config.basesecret
config.basesecret # noqa: B018

def test_devpi_serverdir_env(self, tmpdir, monkeypatch):
monkeypatch.setenv("DEVPI_SERVERDIR", tmpdir.strpath)
Expand Down
2 changes: 1 addition & 1 deletion server/test_devpi_server/test_keyfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ def test_change_subscription_fails(self, keyfs, queue, pool):

def failing(event):
queue.put("willfail")
0/0
0/0 # noqa: B018

keyfs.notifier.on_key_change(key1, failing)
keyfs.notifier.on_key_change(key1, queue.put)
Expand Down
2 changes: 1 addition & 1 deletion server/test_devpi_server/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_taglogger_prefix(caplog):

def test_taglogger_exception(taglogger, caplog):
try:
0/0
0 / 0 # noqa: B018
except Exception:
taglogger.exception("this")
assert caplog.getrecords()[0].exc_info
Expand Down
22 changes: 11 additions & 11 deletions web/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
from test_devpi_server.conftest import gentmp, httpget, makemapp # noqa
from test_devpi_server.conftest import maketestapp, makexom, mapp # noqa
from test_devpi_server.conftest import pypiurls, testapp, pypistage # noqa
from test_devpi_server.conftest import dummyrequest, pypiurls, testapp # noqa
from test_devpi_server.conftest import simpypi, simpypiserver # noqa
from test_devpi_server.conftest import storage_info # noqa
from test_devpi_server.conftest import mock, pyramidconfig # noqa
from test_devpi_server.conftest import speed_up_sqlite # noqa
from test_devpi_server.conftest import speed_up_sqlite_fs # noqa
from test_devpi_server.conftest import gentmp, httpget, makemapp # noqa: F401
from test_devpi_server.conftest import maketestapp, makexom, mapp # noqa: F401
from test_devpi_server.conftest import pypiurls, testapp, pypistage # noqa: F401
from test_devpi_server.conftest import dummyrequest # noqa: F401
from test_devpi_server.conftest import simpypi, simpypiserver # noqa: F401
from test_devpi_server.conftest import storage_info # noqa: F401
from test_devpi_server.conftest import mock, pyramidconfig # noqa: F401
from test_devpi_server.conftest import speed_up_sqlite # noqa: F401
from test_devpi_server.conftest import speed_up_sqlite_fs # noqa: F401
try:
from test_devpi_server.conftest import lower_argon2_parameters # noqa
from test_devpi_server.conftest import lower_argon2_parameters # noqa: F401
except ImportError:
pass
import pytest


(makexom,) # shut up pyflakes
(makexom,) # noqa: B018 shut up pyflakes


def pytest_addoption(parser):
Expand Down
2 changes: 1 addition & 1 deletion web/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def __init__(self):

def create_app(self):
# if the webserver is started, we fail
0 / 0
0 / 0 # noqa: B018

calls = []

Expand Down

0 comments on commit 09f6747

Please sign in to comment.