From d5d63fd7e8848afaf18932c5cbee3598d7316a2f Mon Sep 17 00:00:00 2001 From: Reid 'arrdem' McKenzie Date: Fri, 15 Jul 2022 19:37:34 -0600 Subject: [PATCH] Fmt. --- projects/cram/src/python/cram/__main__.py | 3 +-- projects/cram/src/python/cram/v1.py | 3 +-- projects/shoggoth/src/python/ichor/__init__.py | 1 - projects/shoggoth/src/python/ichor/__main__.py | 8 +++++++- projects/shoggoth/src/python/ichor/assembler.py | 5 ++--- projects/shoggoth/src/python/ichor/bootstrap.py | 5 ++--- projects/shoggoth/src/python/ichor/impl.py | 12 ++++++++++-- projects/shoggoth/src/python/ichor/isa.py | 2 -- projects/shoggoth/src/python/ichor/state.py | 8 +++----- projects/shoggoth/src/python/shoggoth/analyzer.py | 7 +------ projects/shoggoth/test/python/ichor/fixtures.py | 3 +-- .../shoggoth/test/python/ichor/test_assembler.py | 2 +- .../shoggoth/test/python/ichor/test_bootstrap.py | 2 +- .../shoggoth/test/python/ichor/test_interpreter.py | 7 ++++++- projects/shoggoth/test/python/ichor/test_parsers.py | 5 ++--- projects/shoggoth/test/python/ichor/test_state.py | 2 -- 16 files changed, 38 insertions(+), 37 deletions(-) diff --git a/projects/cram/src/python/cram/__main__.py b/projects/cram/src/python/cram/__main__.py index 4bf8085..9d33b11 100644 --- a/projects/cram/src/python/cram/__main__.py +++ b/projects/cram/src/python/cram/__main__.py @@ -17,10 +17,9 @@ from . import ( from .v0 import PackageV0, ProfileV0 from .v1 import PackageV1, ProfileV1 -from vfs import Vfs - import click from toposort import toposort_flatten +from vfs import Vfs log = logging.getLogger(__name__) diff --git a/projects/cram/src/python/cram/v1.py b/projects/cram/src/python/cram/v1.py index 2118f44..76c6ff1 100644 --- a/projects/cram/src/python/cram/v1.py +++ b/projects/cram/src/python/cram/v1.py @@ -11,9 +11,8 @@ from typing import List, Optional, Union from .common import Package, sh, stow -from vfs import Vfs - import toml +from vfs import Vfs def tempf(name): diff --git a/projects/shoggoth/src/python/ichor/__init__.py b/projects/shoggoth/src/python/ichor/__init__.py index c30965d..375fa7c 100644 --- a/projects/shoggoth/src/python/ichor/__init__.py +++ b/projects/shoggoth/src/python/ichor/__init__.py @@ -10,4 +10,3 @@ from ichor.bootstrap import * # noqa from ichor.impl import * # noqa from ichor.isa import * # noqa from ichor.typing import * # noqa -from ichor.assembler import * diff --git a/projects/shoggoth/src/python/ichor/__main__.py b/projects/shoggoth/src/python/ichor/__main__.py index f4bc616..f74cd07 100644 --- a/projects/shoggoth/src/python/ichor/__main__.py +++ b/projects/shoggoth/src/python/ichor/__main__.py @@ -4,7 +4,13 @@ ichor entrypoint """ -from . import Opcode, Interpreter, BOOTSTRAP, XOR3, NOT1, TRUE, FALSE +from . import ( + BOOTSTRAP, + Interpreter, + NOT1, + Opcode, + TRUE, +) def main(): diff --git a/projects/shoggoth/src/python/ichor/assembler.py b/projects/shoggoth/src/python/ichor/assembler.py index 6b487e9..0088003 100644 --- a/projects/shoggoth/src/python/ichor/assembler.py +++ b/projects/shoggoth/src/python/ichor/assembler.py @@ -1,15 +1,14 @@ #!/usr/bin/env python3 -from dataclasses import dataclass from random import choices from string import ascii_lowercase, digits -from typing import Generator, List, Union, Optional, Sequence +from typing import List, Optional, Sequence, Union from ichor import isa def gensym(prefix = None) -> isa.Label: - frag = ''.join(choices(ascii_lowercase + digits, k=8)) + frag = "".join(choices(ascii_lowercase + digits, k=8)) return isa.Label(f"{prefix or 'gensym'}_{frag}") diff --git a/projects/shoggoth/src/python/ichor/bootstrap.py b/projects/shoggoth/src/python/ichor/bootstrap.py index 7fc2682..494eaff 100644 --- a/projects/shoggoth/src/python/ichor/bootstrap.py +++ b/projects/shoggoth/src/python/ichor/bootstrap.py @@ -6,7 +6,6 @@ Hopefully no "real" interpreter ever uses this code, since it's obviously replac from ichor import isa from ichor.state import Module, Variant -from ichor.assembler import FuncBuilder BOOTSTRAP = Module() @@ -15,8 +14,8 @@ BOOL = BOOTSTRAP.define_type( ";bool;true(),false()", ) -TRUE = Variant(BOOL, 'true', ()) -FALSE = Variant(BOOL, 'false', ()) +TRUE = Variant(BOOL, "true", ()) +FALSE = Variant(BOOL, "false", ()) NOT1 = BOOTSTRAP.define_function( f";not;{BOOL};{BOOL}", diff --git a/projects/shoggoth/src/python/ichor/impl.py b/projects/shoggoth/src/python/ichor/impl.py index e5d5030..0b4f930 100644 --- a/projects/shoggoth/src/python/ichor/impl.py +++ b/projects/shoggoth/src/python/ichor/impl.py @@ -10,11 +10,19 @@ context (a virtual machine) which DOES have an easily introspected and serialize from copy import deepcopy -import typing as t from textwrap import indent from ichor import isa -from ichor.state import Closure, FunctionRef, Identifier, Module, Function, Type, TypeRef, VariantRef, Variant, Stackframe +from ichor.state import ( + Closure, + FunctionRef, + Identifier, + Module, + Stackframe, + TypeRef, + Variant, + VariantRef, +) class InterpreterError(Exception): diff --git a/projects/shoggoth/src/python/ichor/isa.py b/projects/shoggoth/src/python/ichor/isa.py index 0c6d839..f030741 100644 --- a/projects/shoggoth/src/python/ichor/isa.py +++ b/projects/shoggoth/src/python/ichor/isa.py @@ -2,7 +2,6 @@ from abc import ABC from dataclasses import dataclass -import typing as t @dataclass @@ -239,4 +238,3 @@ class VLOAD(Opcode): @dataclass class BREAK(Opcode): """Abort the interpreter.""" - pass diff --git a/projects/shoggoth/src/python/ichor/state.py b/projects/shoggoth/src/python/ichor/state.py index 623cce3..54985bd 100644 --- a/projects/shoggoth/src/python/ichor/state.py +++ b/projects/shoggoth/src/python/ichor/state.py @@ -5,9 +5,7 @@ import typing as t from ichor import isa - -from pyrsistent import pdeque, PDeque -from lark import Lark, Transformer, v_args, Token +from lark import Lark, Token, Transformer, v_args class Identifier(t.NamedTuple): @@ -62,7 +60,7 @@ class FuncT(Transformer): return name -FUNC = Lark(GRAMMAR, start="fun", parser='lalr', transformer=FuncT()) +FUNC = Lark(GRAMMAR, start="fun", parser="lalr", transformer=FuncT()) class FunctionRef(t.NamedTuple): @@ -120,7 +118,7 @@ class TypeT(FuncT): -TYPE = Lark(GRAMMAR, start="var", parser='lalr', transformer=TypeT()) +TYPE = Lark(GRAMMAR, start="var", parser="lalr", transformer=TypeT()) class TypeRef(t.NamedTuple): diff --git a/projects/shoggoth/src/python/shoggoth/analyzer.py b/projects/shoggoth/src/python/shoggoth/analyzer.py index efd7538..c611ee3 100644 --- a/projects/shoggoth/src/python/shoggoth/analyzer.py +++ b/projects/shoggoth/src/python/shoggoth/analyzer.py @@ -6,12 +6,7 @@ from abc import ABC from dataclasses import dataclass import typing as t -from shoggoth.types import ( - Keyword, - List, - Symbol, - Vec, -) +from shoggoth.types import Keyword, List, Symbol @dataclass diff --git a/projects/shoggoth/test/python/ichor/fixtures.py b/projects/shoggoth/test/python/ichor/fixtures.py index 1f973b4..c768183 100644 --- a/projects/shoggoth/test/python/ichor/fixtures.py +++ b/projects/shoggoth/test/python/ichor/fixtures.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 -from ichor import Interpreter, BOOTSTRAP - +from ichor import BOOTSTRAP, Interpreter import pytest diff --git a/projects/shoggoth/test/python/ichor/test_assembler.py b/projects/shoggoth/test/python/ichor/test_assembler.py index 0ec2ee2..63a7eb0 100644 --- a/projects/shoggoth/test/python/ichor/test_assembler.py +++ b/projects/shoggoth/test/python/ichor/test_assembler.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 from ichor import FuncBuilder, isa - import pytest + @pytest.fixture def builder() -> FuncBuilder: return FuncBuilder() diff --git a/projects/shoggoth/test/python/ichor/test_bootstrap.py b/projects/shoggoth/test/python/ichor/test_bootstrap.py index 2e338e6..a805e03 100644 --- a/projects/shoggoth/test/python/ichor/test_bootstrap.py +++ b/projects/shoggoth/test/python/ichor/test_bootstrap.py @@ -2,7 +2,7 @@ from .fixtures import * # noqa -from ichor import isa, TRUE, FALSE, NOT1 +from ichor import FALSE, isa, NOT1, TRUE import pytest diff --git a/projects/shoggoth/test/python/ichor/test_interpreter.py b/projects/shoggoth/test/python/ichor/test_interpreter.py index 4992355..f5edffd 100644 --- a/projects/shoggoth/test/python/ichor/test_interpreter.py +++ b/projects/shoggoth/test/python/ichor/test_interpreter.py @@ -4,7 +4,12 @@ Tests coverign the VM interpreter from .fixtures import * # noqa -from ichor import isa, InterpreterError, TRUE, FALSE +from ichor import ( + FALSE, + InterpreterError, + isa, + TRUE, +) import pytest diff --git a/projects/shoggoth/test/python/ichor/test_parsers.py b/projects/shoggoth/test/python/ichor/test_parsers.py index 40ac275..cf70f3a 100644 --- a/projects/shoggoth/test/python/ichor/test_parsers.py +++ b/projects/shoggoth/test/python/ichor/test_parsers.py @@ -1,11 +1,10 @@ #!/usr/bin/env python3 from ichor.state import FUNC, TYPE - import pytest -@pytest.mark.parametrize('sig,parse', [ +@pytest.mark.parametrize("sig,parse", [ (";not;bool;bool", ((), "not", ("bool",), ("bool",))), (";and;bool,bool;bool", ((), "and", ("bool", "bool"), ("bool",))), (";or;bool,bool,bool;bool", ((), "or", ("bool", "bool", "bool"), ("bool",))), @@ -14,7 +13,7 @@ def test_func_parses(sig, parse): assert FUNC.parse(sig) == parse -@pytest.mark.parametrize('sig,parse', [ +@pytest.mark.parametrize("sig,parse", [ (";bool;true(),false()", ((), "bool", (("true", ()), ("false", ())))), ("A,B;pair;pair(a:A,b:B)", (("A", "B"), "pair", (("pair", (("a", "A"), ("b", "B"))),))), ]) diff --git a/projects/shoggoth/test/python/ichor/test_state.py b/projects/shoggoth/test/python/ichor/test_state.py index 6645618..7ea65f9 100644 --- a/projects/shoggoth/test/python/ichor/test_state.py +++ b/projects/shoggoth/test/python/ichor/test_state.py @@ -3,8 +3,6 @@ """Tests covering the Ichor ISA and state model.""" from ichor.impl import Stackframe -from ichor.state import * - import pytest