Skip to content

Commit

Permalink
chore: Avoid single-letter variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Jul 20, 2024
1 parent 0579cf2 commit 3e8d3a4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion scrapyd/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_project_list(config):
"""
eggstorage = initialize_component(config, "eggstorage", "scrapyd.eggstorage.FilesystemEggStorage")
projects = eggstorage.list_projects()
projects.extend(x[0] for x in config.items("settings", default=[]))
projects.extend(project for project, _ in config.items("settings", default=[]))
return projects


Expand Down
4 changes: 2 additions & 2 deletions scrapyd/webservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def render_OPTIONS(self, txrequest):

class DaemonStatus(WsResource):
def render_GET(self, txrequest):
pending = sum(q.count() for q in self.root.scheduler.queues.values())
pending = sum(queue.count() for queue in self.root.scheduler.queues.values())
running = len(self.root.launcher.processes)
finished = len(self.root.launcher.finished)

Expand Down Expand Up @@ -227,7 +227,7 @@ def render_POST(self, txrequest, project, job, signal):

prevstate = None

if self.root.scheduler.queues[project].remove(lambda x: x["_job"] == job):
if self.root.scheduler.queues[project].remove(lambda message: message["_job"] == job):
prevstate = "pending"

spiders = self.root.launcher.processes.values()
Expand Down
22 changes: 11 additions & 11 deletions tests/test_jobstorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from scrapyd.interfaces import IJobStorage
from scrapyd.jobstorage import Job, MemoryJobStorage, SqliteJobStorage

j1 = Job("p1", "s1", end_time=datetime.datetime(2001, 2, 3, 4, 5, 6, 7))
j2 = Job("p2", "s2", end_time=datetime.datetime(2001, 2, 3, 4, 5, 6, 8))
j3 = Job("p3", "s3", end_time=datetime.datetime(2001, 2, 3, 4, 5, 6, 9))
job1 = Job("p1", "s1", end_time=datetime.datetime(2001, 2, 3, 4, 5, 6, 7))
job2 = Job("p2", "s2", end_time=datetime.datetime(2001, 2, 3, 4, 5, 6, 8))
job3 = Job("p3", "s3", end_time=datetime.datetime(2001, 2, 3, 4, 5, 6, 9))


def pytest_generate_tests(metafunc):
Expand Down Expand Up @@ -36,25 +36,25 @@ def test_add(self, cls, tmpdir):

assert len(jobstorage) == 0

jobstorage.add(j1)
jobstorage.add(j2)
jobstorage.add(j3)
jobstorage.add(job1)
jobstorage.add(job2)
jobstorage.add(job3)
actual = jobstorage.list()

assert len(jobstorage) == 2
assert actual == list(jobstorage)
assert actual == [j3, j2]
assert actual == [job3, job2]

def test_iter(self, cls, tmpdir):
jobstorage = cls(config(tmpdir))

assert len(jobstorage) == 0

jobstorage.add(j1)
jobstorage.add(j2)
jobstorage.add(j3)
jobstorage.add(job1)
jobstorage.add(job2)
jobstorage.add(job3)
actual = jobstorage.list()

assert len(jobstorage) == 2
assert actual == list(jobstorage)
assert actual == [j3, j2]
assert actual == [job3, job2]

0 comments on commit 3e8d3a4

Please sign in to comment.