Replaced pylint with ruff

This commit is contained in:
Johan B.W. de Vries 2023-11-15 12:06:25 +01:00
parent 4236340ff6
commit 167560d7dd
10 changed files with 11 additions and 21 deletions

View File

@ -28,7 +28,7 @@ test: venv/.done $(subst .json,.py,$(subst /generator_,/test_generated_,$(wildca
venv/bin/pytest tests $(TEST_FLAGS) venv/bin/pytest tests $(TEST_FLAGS)
lint: venv/.done lint: venv/.done
venv/bin/pylint phasm venv/bin/ruff check phasm tests/integration/helpers.py tests/integration/runners.py
typecheck: venv/.done typecheck: venv/.done
venv/bin/mypy --strict phasm tests/integration/helpers.py tests/integration/runners.py venv/bin/mypy --strict phasm tests/integration/helpers.py tests/integration/runners.py

View File

@ -1,7 +1,7 @@
""" """
This module contains the code to convert parsed Ourlang into WebAssembly code This module contains the code to convert parsed Ourlang into WebAssembly code
""" """
from typing import List, Optional, Union from typing import List, Optional
import struct import struct

View File

@ -5,11 +5,6 @@ from typing import Dict, Iterable, List, Optional, Union
import enum import enum
from typing_extensions import Final
WEBASSEMBLY_BUILTIN_FLOAT_OPS: Final = ('abs', 'sqrt', 'ceil', 'floor', 'trunc', 'nearest', )
WEBASSEMBLY_BUILTIN_BYTES_OPS: Final = ('len', )
from .type3 import types as type3types from .type3 import types as type3types
from .type3.types import Type3, Type3OrPlaceholder, PlaceholderForType, StructType3 from .type3.types import Type3, Type3OrPlaceholder, PlaceholderForType, StructType3

View File

@ -1,7 +1,7 @@
""" """
Parses the source code from the plain text into a syntax tree Parses the source code from the plain text into a syntax tree
""" """
from typing import Any, Dict, List, NoReturn, Union from typing import Any, Dict, NoReturn, Union
import ast import ast
@ -16,7 +16,7 @@ from .ourlang import (
Expression, Expression,
BinaryOp, BinaryOp,
ConstantPrimitive, ConstantMemoryStored, ConstantPrimitive,
ConstantBytes, ConstantTuple, ConstantStruct, ConstantBytes, ConstantTuple, ConstantStruct,
TupleInstantiation, TupleInstantiation,
@ -219,7 +219,7 @@ class OurVisitor:
if not isinstance(stmt.target, ast.Name): if not isinstance(stmt.target, ast.Name):
raise NotImplementedError('Class with default values') raise NotImplementedError('Class with default values')
if not stmt.value is None: if stmt.value is not None:
raise NotImplementedError('Class with default values') raise NotImplementedError('Class with default values')
if stmt.simple != 1: if stmt.simple != 1:
@ -591,7 +591,7 @@ class OurVisitor:
if not isinstance(node.func.ctx, ast.Load): if not isinstance(node.func.ctx, ast.Load):
_raise_static_error(node.func, 'Must be load context') _raise_static_error(node.func, 'Must be load context')
if not node.func.id in module.struct_definitions: if node.func.id not in module.struct_definitions:
_raise_static_error(node.func, 'Undefined struct') _raise_static_error(node.func, 'Undefined struct')
if node.keywords: if node.keywords:

View File

@ -1,5 +1,3 @@
from typing import Union
from .type3 import types as type3types from .type3 import types as type3types
def calculate_alloc_size(typ: type3types.Type3, is_member: bool = False) -> int: def calculate_alloc_size(typ: type3types.Type3, is_member: bool = False) -> int:
@ -49,7 +47,7 @@ def calculate_alloc_size(typ: type3types.Type3, is_member: bool = False) -> int:
assert not isinstance(arg, type3types.IntType3) assert not isinstance(arg, type3types.IntType3)
if isinstance(arg, type3types.PlaceholderForType): if isinstance(arg, type3types.PlaceholderForType):
assert not arg.resolve_as is None assert arg.resolve_as is not None
arg = arg.resolve_as arg = arg.resolve_as
size += calculate_alloc_size(arg, is_member=True) size += calculate_alloc_size(arg, is_member=True)

View File

@ -103,7 +103,6 @@ class SameTypeConstraint(ConstraintBase):
def check(self) -> CheckResult: def check(self) -> CheckResult:
known_types: List[types.Type3] = [] known_types: List[types.Type3] = []
placeholders = [] placeholders = []
do_applied_placeholder_check: bool = False
for typ in self.type_list: for typ in self.type_list:
if isinstance(typ, types.IntType3): if isinstance(typ, types.IntType3):
known_types.append(typ) known_types.append(typ)
@ -115,7 +114,6 @@ class SameTypeConstraint(ConstraintBase):
if isinstance(typ, types.AppliedType3): if isinstance(typ, types.AppliedType3):
known_types.append(typ) known_types.append(typ)
do_applied_placeholder_check = True
continue continue
if isinstance(typ, types.PlaceholderForType): if isinstance(typ, types.PlaceholderForType):

View File

@ -138,7 +138,7 @@ def expression(ctx: Context, inp: ourlang.Expression) -> ConstraintGenerator:
yield SameTypeConstraint( yield SameTypeConstraint(
inp.type3, inp.type3,
type3types.AppliedType3(type3types.tuple, r_type), type3types.AppliedType3(type3types.tuple, r_type),
comment=f'The type of a tuple is a combination of its members' comment='The type of a tuple is a combination of its members'
) )
return return
@ -178,7 +178,7 @@ def statement_if(ctx: Context, fun: ourlang.Function, inp: ourlang.StatementIf)
yield from expression(ctx, inp.test) yield from expression(ctx, inp.test)
yield SameTypeConstraint(inp.test.type3, type3types.bool_, yield SameTypeConstraint(inp.test.type3, type3types.bool_,
comment=f'Must pass a boolean expression to if') comment='Must pass a boolean expression to if')
for stmt in inp.statements: for stmt in inp.statements:
yield from statement(ctx, fun, stmt) yield from statement(ctx, fun, stmt)

View File

@ -1,7 +1,7 @@
""" """
Entry point to the type3 system Entry point to the type3 system
""" """
from typing import Any, Dict, List, Set from typing import Dict, List
from .. import codestyle from .. import codestyle
from .. import ourlang from .. import ourlang

View File

@ -1,10 +1,10 @@
mypy==0.991 mypy==0.991
pygments==2.12.0 pygments==2.12.0
pylint==2.15.9
pytest==7.2.0 pytest==7.2.0
pytest-integration==0.2.2 pytest-integration==0.2.2
pywasm==1.0.7 pywasm==1.0.7
pywasm3==0.5.0 pywasm3==0.5.0
ruff==0.1.5
wasmer==1.1.0 wasmer==1.1.0
wasmer_compiler_cranelift==1.1.0 wasmer_compiler_cranelift==1.1.0
wasmtime==3.0.0 wasmtime==3.0.0

View File

@ -195,7 +195,6 @@ def _allocate_memory_stored_value(
val_el_typ = val_typ.args[0] val_el_typ = val_typ.args[0]
assert not isinstance(val_el_typ, type3types.PlaceholderForType) assert not isinstance(val_el_typ, type3types.PlaceholderForType)
val_el_alloc_size = calculate_alloc_size(val_el_typ)
tuple_len_obj = val_typ.args[1] tuple_len_obj = val_typ.args[1]
assert isinstance(tuple_len_obj, type3types.IntType3) assert isinstance(tuple_len_obj, type3types.IntType3)