Msc. lint stomping

This commit is contained in:
Reid 'arrdem' McKenzie 2021-08-30 00:30:44 -06:00
parent 5756f7dd07
commit 1684195192
6 changed files with 29 additions and 29 deletions

View file

@ -127,9 +127,9 @@ def available_migrations(queries: Queries, conn) -> t.Iterable[MigrationDescript
if query_name.endswith("_cursor"): if query_name.endswith("_cursor"):
continue continue
# type: query_name: str # query_name: str
# query_fn: t.Callable + {.__name__, .__doc__, .sql}
query_fn = getattr(queries, query_name) query_fn = getattr(queries, query_name)
# type: query_fn: t.Callable + {.__name__, .__doc__, .sql}
yield MigrationDescriptor( yield MigrationDescriptor(
name = query_name, name = query_name,
committed_at = None, committed_at = None,

View file

@ -1,12 +1,12 @@
"""A quick and dirty Python driver for the jobqd API.""" """A quick and dirty Python driver for the jobqd API."""
from datetime import datetime from datetime import datetime
from typing import NamedTuple import typing as t
import requests import requests
class Job(NamedTuple): class Job(t.NamedTuple):
id: int id: int
payload: object payload: object
events: object events: object
@ -39,7 +39,7 @@ class JobqClient(object):
.get("jobs"): .get("jobs"):
yield Job.from_json(job) 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.""" """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( return Job.from_json(
@ -49,7 +49,7 @@ class JobqClient(object):
"state": state}) "state": state})
.json()) .json())
def create(self, payload: object, state=None) -> DehydratedJob: def create(self, payload: object, state=None) -> Job:
"""Create a new job in the system.""" """Create a new job in the system."""
return Job.from_json( return Job.from_json(
@ -59,7 +59,7 @@ class JobqClient(object):
"state": state}) "state": state})
.json()) .json())
def fetch(self, job: Job) -> HydratedJob: def fetch(self, job: Job) -> Job:
"""Fetch the current state of a job.""" """Fetch the current state of a job."""
return Job.from_json( return Job.from_json(
@ -77,7 +77,7 @@ class JobqClient(object):
"new": state}) "new": state})
.json()) .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.""" """Attempt to record an event against a job."""
return Job.from_json( return Job.from_json(

View file

@ -54,14 +54,14 @@ def repl(opts, args, runtime):
try: try:
expr = parse_expr(line) expr = parse_expr(line)
except Exception as e: except Exception:
traceback.print_exc() traceback.print_exc()
continue continue
try: try:
result = lil_eval(runtime, module, Bindings("__root__", None), expr) result = lil_eval(runtime, module, Bindings("__root__", None), expr)
print_([("class:result", f"{result!r}")], style=STYLE) print_([("class:result", f"{result!r}")], style=STYLE)
except Exception as e: except Exception:
traceback.print_exc() traceback.print_exc()
continue continue
@ -145,15 +145,15 @@ def main():
def py(runtime=None, module=None, expr=None, body=None, name=None): def py(runtime=None, module=None, expr=None, body=None, name=None):
"""The implementation of the Python lang as an eval type.""" """The implementation of the Python lang as an eval type."""
g = globals().copy() globs = globals().copy()
l = {} locs = {}
body = ( body = (
f"def _shim():\n" "def _shim():\n"
+ "\n".join(" " + l for l in body.splitlines()) + "\n".join(" " + line for line in body.splitlines())
+ "\n\n_escape = _shim()" + "\n\n_escape = _shim()"
) )
exec(body, g, l) exec(body, globs, locs)
return l["_escape"] return locs["_escape"]
def lil(runtime=None, module=None, expr=None, body=None, name=None): def lil(runtime=None, module=None, expr=None, body=None, name=None):
"""The implementation of the Lilith lang as an eval type.""" """The implementation of the Lilith lang as an eval type."""

View file

@ -141,7 +141,7 @@ class Proquint(object):
"""Encode an integer into a proquint string.""" """Encode an integer into a proquint string."""
if width % 8 != 0 or width < 8: 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")) return cls.encode_bytes(val.to_bytes(width // 8, "big"))