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

Address complaints from pylint extensions #393

Merged
merged 2 commits into from
Oct 4, 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 apport/crashdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def known(self, report):
contents = dupdb_url.read().decode("UTF-8")
if "<title>404 Not Found" in contents:
continue
except (OSError, urllib.error.URLError):
except OSError:
# does not exist, failed to load, etc.
continue

Expand Down
8 changes: 4 additions & 4 deletions apport/packaging_impl/apt_dpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@
try:
with urllib.request.urlopen(url) as response:
content = response.read()
except (urllib.error.URLError, urllib.error.HTTPError):
except urllib.error.URLError:
apport.logging.warning("cannot connect to: %s", urllib.parse.unquote(url))
return None
except OSError:
Expand Down Expand Up @@ -1736,7 +1736,7 @@
) as response:
response.read()
return user, ppa_name
except (urllib.error.URLError, urllib.error.HTTPError):
except urllib.error.URLError:
index += 1
if index == len(components):
if try_ppa:
Expand Down Expand Up @@ -1786,7 +1786,7 @@
debug_entry.comps = ["main/debug"]
debug_entry.suites = [release_codename]
return [main_entry, debug_entry]
except (urllib.error.URLError, urllib.error.HTTPError):
except urllib.error.URLError:

Check warning on line 1789 in apport/packaging_impl/apt_dpkg.py

View check run for this annotation

Codecov / codecov/patch

apport/packaging_impl/apt_dpkg.py#L1789

Added line #L1789 was not covered by tests
return [main_entry]
else:
ppa_line = (
Expand All @@ -1797,7 +1797,7 @@
with contextlib.closing(urllib.request.urlopen(debug_url)) as response:
response.read()
add_debug = " main/debug"
except (urllib.error.URLError, urllib.error.HTTPError):
except urllib.error.URLError:

Check warning on line 1800 in apport/packaging_impl/apt_dpkg.py

View check run for this annotation

Codecov / codecov/patch

apport/packaging_impl/apt_dpkg.py#L1800

Added line #L1800 was not covered by tests
add_debug = ""
return [
SourceEntry(ppa_line + add_debug),
Expand Down
2 changes: 1 addition & 1 deletion apport/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ def search_bug_patterns(self, url: str | None) -> str | None:
try:
with urllib.request.urlopen(url) as request:
patterns = request.read().decode("UTF-8", errors="replace")
except (OSError, urllib.error.URLError):
except OSError:
# doesn't exist or failed to load
return None

Expand Down
6 changes: 3 additions & 3 deletions data/apport
Original file line number Diff line number Diff line change
Expand Up @@ -809,13 +809,13 @@ def receive_arguments_via_socket() -> argparse.Namespace:
sys.exit(0)

# Extract and validate the fd
fds = listen_fds()
if len(fds) < 1:
socket_fds = listen_fds()
if len(socket_fds) < 1:
logging.getLogger().error("Invalid socket activation, no fd provided")
sys.exit(1)

# Open the socket
sock = socket.fromfd(int(fds[0]), socket.AF_UNIX, socket.SOCK_STREAM)
sock = socket.fromfd(int(socket_fds[0]), socket.AF_UNIX, socket.SOCK_STREAM)
atexit.register(sock.shutdown, socket.SHUT_RDWR)

# Replace stdin by the socket activation fd
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ load-plugins = [
"pylint.extensions.dunder",
"pylint.extensions.eq_without_hash",
"pylint.extensions.no_self_use",
"pylint.extensions.overlapping_exceptions",
"pylint.extensions.private_import",
"pylint.extensions.redefined_variable_type",
"pylint.extensions.set_membership",
"pylint.extensions.typing",
]
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_problem_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ def test_extract_keys(self):
os.path.join(self.workdir, "nonexistent"),
)
# Test exception handling: Non-binary and nonexistent key
tests = [
exception_tests = [
(ValueError, "Txt"),
(ValueError, ["Foo", "Txt"]),
(KeyError, "Bar"),
(KeyError, ["Foo", "Bar"]),
]
for exc, keys_arg in tests:
for exc, keys_arg in exception_tests:
report.seek(0)
self.assertRaises(exc, pr.extract_keys, report, keys_arg, self.workdir)

Expand Down
Loading