From 1684195192ac6e58ec3e0e5b3f411404b14a18a0 Mon Sep 17 00:00:00 2001 From: Reid 'arrdem' McKenzie Date: Mon, 30 Aug 2021 00:30:44 -0600 Subject: [PATCH] Msc. lint stomping --- .../src/python/anosql_migrations.py | 4 +-- projects/jobq/src/python/jobq/__init__.py | 2 +- projects/jobqd/src/python/jobqd/rest/api.py | 26 +++++++++---------- projects/lilith/src/python/lilith/__main__.py | 16 ++++++------ .../proquint/src/python/proquint/__init__.py | 2 +- .../proquint/test/python/test_hypothesis.py | 8 +++--- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/projects/anosql-migrations/src/python/anosql_migrations.py b/projects/anosql-migrations/src/python/anosql_migrations.py index 1cc581b..a8fb8ca 100644 --- a/projects/anosql-migrations/src/python/anosql_migrations.py +++ b/projects/anosql-migrations/src/python/anosql_migrations.py @@ -127,9 +127,9 @@ def available_migrations(queries: Queries, conn) -> t.Iterable[MigrationDescript if query_name.endswith("_cursor"): continue - # type: query_name: str + # query_name: str + # query_fn: t.Callable + {.__name__, .__doc__, .sql} query_fn = getattr(queries, query_name) - # type: query_fn: t.Callable + {.__name__, .__doc__, .sql} yield MigrationDescriptor( name = query_name, committed_at = None, diff --git a/projects/jobq/src/python/jobq/__init__.py b/projects/jobq/src/python/jobq/__init__.py index 9752f55..6bdf20c 100644 --- a/projects/jobq/src/python/jobq/__init__.py +++ b/projects/jobq/src/python/jobq/__init__.py @@ -234,7 +234,7 @@ class JobQueue(object): yield next(iterable) except StopIteration: break - jobs = lf(jobs) + jobs = lf(jobs) return self._from_results(jobs) diff --git a/projects/jobqd/src/python/jobqd/rest/api.py b/projects/jobqd/src/python/jobqd/rest/api.py index e7f70f5..c8c12a1 100644 --- a/projects/jobqd/src/python/jobqd/rest/api.py +++ b/projects/jobqd/src/python/jobqd/rest/api.py @@ -1,12 +1,12 @@ """A quick and dirty Python driver for the jobqd API.""" from datetime import datetime -from typing import NamedTuple +import typing as t import requests -class Job(NamedTuple): +class Job(t.NamedTuple): id: int payload: object events: object @@ -16,11 +16,11 @@ class Job(NamedTuple): @classmethod def from_json(cls, obj): return cls( - id = int(obj["id"]), - payload = obj["payload"], - events = obj["events"], - state = obj["state"], - modified = datetime.fromtimestamp(obj["modified"]) + id=int(obj["id"]), + payload=obj["payload"], + events=obj["events"], + state=obj["state"], + modified=datetime.fromtimestamp(obj["modified"]) ) @@ -35,11 +35,11 @@ class JobqClient(object): for job in self._session.post(self._url + "/api/v0/job", json={"query": query or [], "limit": limit})\ - .json()\ - .get("jobs"): + .json()\ + .get("jobs"): yield Job.from_json(job) - def poll(self, query, state) -> DehydratedJob: + def poll(self, query, state) -> Job: """Poll the job queue for the first job matching the given query, atomically advancing it to the given state and returning the advanced Job.""" return Job.from_json( @@ -49,7 +49,7 @@ class JobqClient(object): "state": state}) .json()) - def create(self, payload: object, state=None) -> DehydratedJob: + def create(self, payload: object, state=None) -> Job: """Create a new job in the system.""" return Job.from_json( @@ -59,7 +59,7 @@ class JobqClient(object): "state": state}) .json()) - def fetch(self, job: Job) -> HydratedJob: + def fetch(self, job: Job) -> Job: """Fetch the current state of a job.""" return Job.from_json( @@ -77,7 +77,7 @@ class JobqClient(object): "new": state}) .json()) - def event(self, job: Job, event: object) -> HydratedJob: + def event(self, job: Job, event: object) -> Job: """Attempt to record an event against a job.""" return Job.from_json( diff --git a/projects/lilith/src/python/lilith/__main__.py b/projects/lilith/src/python/lilith/__main__.py index 5439d34..ced141d 100644 --- a/projects/lilith/src/python/lilith/__main__.py +++ b/projects/lilith/src/python/lilith/__main__.py @@ -54,14 +54,14 @@ def repl(opts, args, runtime): try: expr = parse_expr(line) - except Exception as e: + except Exception: traceback.print_exc() continue try: result = lil_eval(runtime, module, Bindings("__root__", None), expr) print_([("class:result", f"⇒ {result!r}")], style=STYLE) - except Exception as e: + except Exception: traceback.print_exc() continue @@ -145,15 +145,15 @@ def main(): def py(runtime=None, module=None, expr=None, body=None, name=None): """The implementation of the Python lang as an eval type.""" - g = globals().copy() - l = {} + globs = globals().copy() + locs = {} body = ( - f"def _shim():\n" - + "\n".join(" " + l for l in body.splitlines()) + "def _shim():\n" + + "\n".join(" " + line for line in body.splitlines()) + "\n\n_escape = _shim()" ) - exec(body, g, l) - return l["_escape"] + exec(body, globs, locs) + return locs["_escape"] def lil(runtime=None, module=None, expr=None, body=None, name=None): """The implementation of the Lilith lang as an eval type.""" diff --git a/projects/proquint/src/python/proquint/__init__.py b/projects/proquint/src/python/proquint/__init__.py index 018fad4..e4fed48 100644 --- a/projects/proquint/src/python/proquint/__init__.py +++ b/projects/proquint/src/python/proquint/__init__.py @@ -141,7 +141,7 @@ class Proquint(object): """Encode an integer into a proquint string.""" if width % 8 != 0 or width < 8: - raise ValueError(f"Width must be a positive power of 2 greater than 8") + raise ValueError("Width must be a positive power of 2 greater than 8") return cls.encode_bytes(val.to_bytes(width // 8, "big")) diff --git a/projects/proquint/test/python/test_hypothesis.py b/projects/proquint/test/python/test_hypothesis.py index c459e20..d930643 100644 --- a/projects/proquint/test/python/test_hypothesis.py +++ b/projects/proquint/test/python/test_hypothesis.py @@ -5,25 +5,25 @@ from hypothesis.strategies import integers import proquint -@given(integers(min_value=0, max_value=1<<16)) +@given(integers(min_value=0, max_value=1 << 16)) def test_round_trip_16(val): assert proquint.Proquint.decode( proquint.Proquint.encode(val, 16)) == val -@given(integers(min_value=0, max_value=1<<32)) +@given(integers(min_value=0, max_value=1 << 32)) def test_round_trip_32(val): assert proquint.Proquint.decode( proquint.Proquint.encode(val, 32)) == val -@given(integers(min_value=0, max_value=1<<64)) +@given(integers(min_value=0, max_value=1 << 64)) def test_round_trip_64(val): assert proquint.Proquint.decode( proquint.Proquint.encode(val, 64)) == val -@given(integers(min_value=0, max_value=1<<512)) +@given(integers(min_value=0, max_value=1 << 512)) def test_round_trip_512(val): assert proquint.Proquint.decode( proquint.Proquint.encode(val, 512)) == val