Skip to content

Commit 027fabb

Browse files
committed
Fix line length violations and remove unnecessary PLW0717 suppression from test files
Replace # noqa: LN001 suppressions with properly split strings wrapped in parentheses to satisfy ISC004. Remove PLW0717 from the test file ignore list — test files have no violations so the suppression was unnecessary.
1 parent 7e8a57b commit 027fabb

4 files changed

Lines changed: 40 additions & 12 deletions

File tree

.ruff.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ testing = [
219219
"ARG004", # unused-static-method-argument (hit in WSGI test apps)
220220
"PLC2701", # Allow importing internal files needed for testing
221221
# "PLR6301", # Allow 'self' parameter in method definitions (required for test stubs)
222-
"PLW0717", # too-many-statements-in-try-clause # FIXME
223222
"S101", # Allow use of `assert` in test files
224223
"S404", # Allow importing 'subprocess' module to testing call external tools needed by these hooks
225224
"S603", # subprocess-without-shell-equals-true

cheroot/test/test_conn.py

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ def testing_server(raw_testing_server, monkeypatch):
191191
continue
192192

193193
assert c_msg in raw_testing_server.error_log.ignored_msgs, (
194-
f"Found error in the error log: message = '{c_msg}', level = '{c_level}'\n{c_traceback}" # noqa: LN001
194+
f"Found error in the error log: message = '{c_msg}', "
195+
f"level = '{c_level}'\n{c_traceback}"
195196
)
196197

197198

@@ -788,11 +789,21 @@ def _read_request_line(self):
788789
(logging.WARNING, r'^socket\.error 666$'),
789790
(
790791
logging.INFO,
791-
r'^Got a connection error while handling a connection from .*:\d{1,5} \(666\)', # noqa: LN001
792+
(
793+
r'^Got a connection error while handling a connection '
794+
r'from .*:\d{1,5} \(666\)'
795+
),
792796
),
793797
(
794798
logging.CRITICAL,
795-
r'A fatal exception happened\. Setting the server interrupt flag to ConnectionResetError\(666,?\) and giving up\.\n\nPlease, report this on the Cheroot tracker at <https://github\.com/cherrypy/cheroot/issues/new/choose>, providing a full reproducer with as much context and details as possible\.$', # noqa: LN001
799+
(
800+
r'A fatal exception happened\. Setting the server interrupt flag '
801+
r'to ConnectionResetError\(666,?\) and giving up\.\n\nPlease, '
802+
r'report this on the Cheroot tracker at '
803+
r'<https://github\.com/cherrypy/cheroot/issues/new/choose>, '
804+
r'providing a full reproducer with as much context and details '
805+
r'as possible\.$'
806+
),
796807
),
797808
)
798809

@@ -832,11 +843,17 @@ def _trigger_kb_intr(_req, _resp):
832843
expected_log_entries = (
833844
(
834845
logging.DEBUG,
835-
r'^Got a server shutdown request while handling a connection from .*:\d{1,5} \(simulated test handler keyboard interrupt\)$', # noqa: LN001
846+
(
847+
r'^Got a server shutdown request while handling a connection '
848+
r'from .*:\d{1,5} \(simulated test handler keyboard interrupt\)$'
849+
),
836850
),
837851
(
838852
logging.DEBUG,
839-
r"^Setting the server interrupt flag to KeyboardInterrupt\('simulated test handler keyboard interrupt',?\)$", # noqa: LN001
853+
(
854+
r'^Setting the server interrupt flag to KeyboardInterrupt'
855+
r"\('simulated test handler keyboard interrupt',?\)$"
856+
),
840857
),
841858
(
842859
logging.INFO,
@@ -903,7 +920,10 @@ def _trigger_scary_exc(_req, _resp):
903920
expected_log_entries = (
904921
(
905922
logging.ERROR,
906-
r"^Unhandled error while processing an incoming connection SillyMistake\('simulated unhandled exception 💣 in test handler',?\)$", # noqa: LN001
923+
(
924+
r'^Unhandled error while processing an incoming connection '
925+
r"SillyMistake\('simulated unhandled exception 💣 in test handler',?\)$"
926+
),
907927
),
908928
(
909929
logging.INFO,
@@ -985,7 +1005,10 @@ def _read_request_line(self):
9851005
expected_log_entries = (
9861006
(
9871007
logging.ERROR,
988-
r'^Unhandled error while processing an incoming connection ScaryCrash\(666,?\)$', # noqa: LN001
1008+
(
1009+
r'^Unhandled error while processing an incoming connection '
1010+
r'ScaryCrash\(666,?\)$'
1011+
),
9891012
),
9901013
(
9911014
logging.INFO,

docs/changelog-fragments.d/826.contrib.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ Bumped Ruff to v0.15.18, which introduces new rules:
77

88
Three further new rules are suppressed pending fixes: too many statements
99
in a try clause (PLW0717), non-empty ``__init__`` modules (RUF067), and
10-
starting a process with a partial executable path (S607)
10+
starting a process with a partial executable path (S607).
1111

12-
-- by :user:`julianz-`.
12+
-- by :user:`julianz-`

docs/conf.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,14 @@
107107
r'https://github\.com/cherrypy/cherrypy/tree',
108108
# Has an ephemeral anchor (line-range) but actual HTML has separate per-
109109
# line anchors.
110-
r'https://github\.com/python/cpython/blob/c39b52f/Lib/poplib\.py#L297-L302', # noqa: LN001
111-
r'https://github\.com/python/cpython/blob/c39b52f/Lib/poplib\.py#user-content-L297-L302', # noqa: LN001
110+
(
111+
r'https://github\.com'
112+
r'/python/cpython/blob/c39b52f/Lib/poplib\.py#L297-L302'
113+
),
114+
(
115+
r'https://github\.com'
116+
r'/python/cpython/blob/c39b52f/Lib/poplib\.py#user-content-L297-L302'
117+
),
112118
r'^https://img\.shields\.io/matrix', # these are rate-limited
113119
r'^https://matrix\.to/#', # these render fully on front-end from anchors
114120
r'^https://stackoverflow\.com/', # these generate HTTP 403 Forbidden

0 commit comments

Comments
 (0)