Skip to content

Commit 9c5e2ff

Browse files
authored
Merge pull request #244 from praw-dev/fix-lint-errors
Fix linting errors
2 parents 9465198 + 2220321 commit 9c5e2ff

File tree

5 files changed

+393
-340
lines changed

5 files changed

+393
-340
lines changed

prawcore/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
TIMEOUT = float(
1010
os.environ.get(
1111
"PRAWCORE_TIMEOUT",
12-
os.environ.get("prawcore_timeout", 16), # noqa: SIM112
12+
os.environ.get("prawcore_timeout", "16"), # noqa: SIM112
1313
)
1414
)
1515
WINDOW_SIZE = 600

prawcore/requestor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(
4747
4848
"""
4949
# Imported locally to avoid an import cycle, with __init__
50-
from . import __version__
50+
from . import __version__ # noqa: PLC0415
5151

5252
if user_agent is None or len(user_agent) < self.MIN_USER_AGENT_LENGTH:
5353
msg = "user_agent is not descriptive"

tests/conftest.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,17 @@ def __init__(self, _dict):
6464

6565
placeholders = {
6666
x: env_default(x)
67-
for x in (
68-
"client_id client_secret password permanent_grant_code temporary_grant_code"
69-
" redirect_uri refresh_token user_agent username"
70-
).split()
67+
for x in [
68+
"client_id",
69+
"client_secret",
70+
"password",
71+
"permanent_grant_code",
72+
"temporary_grant_code",
73+
"redirect_uri",
74+
"refresh_token",
75+
"user_agent",
76+
"username",
77+
]
7178
}
7279

7380
if (
@@ -76,9 +83,8 @@ def __init__(self, _dict):
7683
placeholders["basic_auth"] = b64encode(f"{placeholders['client_id']}:".encode()).decode("utf-8")
7784
else:
7885
placeholders["basic_auth"] = b64encode(
79-
f"{placeholders['client_id']}:{placeholders['client_secret']}".encode()
86+
f"{placeholders['client_id']}:{placeholders['client_secret']}".encode(),
8087
).decode("utf-8")
8188

82-
8389
if platform == "darwin": # Work around issue with betamax on OS X # pragma: no cover
8490
socket.gethostbyname = lambda _: "127.0.0.1"

tests/integration/__init__.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""prawcore Integration test suite."""
22

33
import os
4+
from pathlib import Path
45
from urllib.parse import quote_plus
56

67
import betamax
@@ -13,7 +14,7 @@
1314
filter_access_token,
1415
)
1516

16-
CASSETTES_PATH = "tests/integration/cassettes"
17+
CASSETTES_PATH = Path("tests/integration/cassettes")
1718
existing_cassettes = set()
1819
used_cassettes = set()
1920

@@ -24,8 +25,8 @@ class IntegrationTest:
2425
@pytest.fixture(autouse=True, scope="session")
2526
def cassette_tracker(self): # pragma: no cover
2627
"""Track cassettes to ensure unused cassettes are not uploaded."""
27-
for cassette in os.listdir(CASSETTES_PATH):
28-
existing_cassettes.add(cassette[: cassette.rindex(".")])
28+
for cassette in CASSETTES_PATH.iterdir():
29+
existing_cassettes.add(cassette.name[: cassette.name.rindex(".")])
2930
yield
3031
unused_cassettes = existing_cassettes - used_cassettes
3132
if unused_cassettes and os.getenv("ENSURE_NO_UNUSED_CASSETTES", "0") == "1":
@@ -42,16 +43,16 @@ def cassette(self, request, recorder, cassette_name):
4243
# before class markers.
4344
kwargs.setdefault(key, value)
4445
with recorder.use_cassette(cassette_name, **kwargs) as recorder_context:
45-
cassette = recorder_context.current_cassette
46+
_cassette = recorder_context.current_cassette
4647
yield recorder_context
47-
ensure_integration_test(cassette)
48+
ensure_integration_test(_cassette)
4849
used_cassettes.add(cassette_name)
4950

5051
@pytest.fixture(autouse=True)
5152
def recorder(self, requestor):
5253
"""Configure Betamax."""
53-
recorder = betamax.Betamax(requestor)
54-
recorder.register_serializer(PrettyJSONSerializer)
54+
_recorder = betamax.Betamax(requestor)
55+
_recorder.register_serializer(PrettyJSONSerializer)
5556
with betamax.Betamax.configure() as config:
5657
config.cassette_library_dir = CASSETTES_PATH
5758
config.default_cassette_options["serialize_with"] = "prettyjson"
@@ -60,7 +61,7 @@ def recorder(self, requestor):
6061
if key == "password":
6162
value = quote_plus(value) # noqa: PLW2901
6263
config.define_cassette_placeholder(f"<{key.upper()}>", value)
63-
yield recorder
64+
yield _recorder
6465
# since placeholders persist between tests
6566
Cassette.default_cassette_options["placeholders"] = []
6667

0 commit comments

Comments
 (0)