Skip to content

Commit 6b6a02a

Browse files
authored
SCP30 removed setting (#41)
1 parent 3c77edc commit 6b6a02a

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

docs/rules/scp30.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.. _scp30:
2+
3+
======================
4+
SCP30: Removed setting
5+
======================
6+
7+
What it does
8+
============
9+
10+
Reports setting names that have been removed from package versions frozen in
11+
your project requirements but do exist in lower versions of those packages.
12+
13+
It also reports the package that defined the setting, the version in which the
14+
setting was deprecated, and the version in which it was removed, so that you
15+
can check the corresponging release notes for sunset guidance.
16+
17+
Sometimes sunset guidance is also provided in the error message.
18+
19+
Why is this bad?
20+
================
21+
22+
Removed settings have stopped working the way they used to, and instead are
23+
silently ignored.
24+

flake8_scrapy/finders/settings.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ def check_known_name(
125125
if name not in SETTINGS:
126126
return
127127
setting = SETTINGS[name]
128-
deprecated_in = setting.deprecated_in
129128
added_in = setting.added_in
129+
deprecated_in = setting.deprecated_in
130+
removed_in = setting.removed_in
130131
if not deprecated_in and not added_in:
131132
return
132133
package = setting.package
@@ -154,11 +155,16 @@ def check_known_name(
154155
if version < deprecated_in:
155156
return
156157
detail = f"deprecated in {package} {deprecated_in}"
158+
if removed_in and version >= removed_in:
159+
detail += f", removed in {removed_in}"
160+
code, message = 30, "removed setting"
161+
else:
162+
code, message = 28, "deprecated setting"
157163
if setting.sunset_guidance:
158164
detail += f"; {setting.sunset_guidance}"
159165
yield Issue(
160-
28,
161-
"deprecated setting",
166+
code,
167+
message,
162168
detail=detail,
163169
node=resolved_node,
164170
column=column,

tests/test_settings.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,23 @@ def default_issues(
11331133
),
11341134
),
11351135
),
1136+
# SCP30 removed setting
1137+
(
1138+
("scrapy==2.1.0",),
1139+
"LOG_UNSERIALIZABLE_REQUESTS",
1140+
(
1141+
Issue(
1142+
"SCP15 insecure requirement: scrapy 2.11.2 implements security fixes",
1143+
path="requirements.txt",
1144+
),
1145+
Issue(
1146+
"SCP30 removed setting: deprecated in scrapy 2.0.1 or "
1147+
"lower, removed in 2.1.0; use SCHEDULER_DEBUG instead",
1148+
path=path,
1149+
column=column,
1150+
),
1151+
),
1152+
),
11361153
)
11371154
),
11381155
# scrapy_known_settings silences SCP27

0 commit comments

Comments
 (0)