Skip to content

Commit

Permalink
reformatted code
Browse files Browse the repository at this point in the history
  • Loading branch information
BrentBlanckaert committed Oct 24, 2024
1 parent 0d1c9c6 commit 55bbfa1
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 45 deletions.
4 changes: 0 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,6 @@
name = "NODE_PATH";
prefix = "${ast}/lib/node_modules";
}
{
name = "TS_NODE_PROJECT";
prefix = "./tsconfig.json";
}
];
commands = [
{
Expand Down
76 changes: 42 additions & 34 deletions tested/languages/typescript/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

logger = logging.getLogger(__name__)


class TypeScript(Language):

def initial_dependencies(self) -> list[str]:
Expand Down Expand Up @@ -107,9 +108,18 @@ def compilation(self, files: list[str]) -> CallbackResult:
submission = submission_file(self)
main_file = list(filter(lambda x: x == submission, files))
if main_file:
return (["tsc", "--module", "nodenext", "--moduleResolution",
"nodenext", "--noEmit", main_file[0]],
files)
return (
[
"tsc",
"--module",
"nodenext",
"--moduleResolution",
"nodenext",
"--noEmit",
main_file[0],
],
files,
)
else:
return [], files

Expand All @@ -133,7 +143,7 @@ def modify_solution(self, solution: Path):
assert output, "Missing output from TypesScript's modify_solution"
namings = output.stdout.strip()
with open(solution, "a") as file:
# print(f"\ndeclare var module: any;", file=file)
# print(f"\ndeclare var module: any;", file=file)
print(f"\nexport {{{namings}}};", file=file)

# Add strict mode to the script.
Expand Down Expand Up @@ -197,38 +207,36 @@ def generate_encoder(self, values: list[Value]) -> str:

def get_declaration_metadata(self) -> TypeDeclarationMetadata:
return {
"names": { # type: ignore
"integer": "number",
"real": "number",
"char": "string",
"text": "string",
"string": "string",
"boolean": "boolean",
"sequence": "array",
"set": "set",
"map": "object",
"nothing": "null",
"undefined": "undefined",
"int8": "number",
"uint8": "number",
"int16": "number",
"uint16": "number",
"int32": "number",
"uint32": "number",
"int64": "number",
"uint64": "number",
"bigint": "number",
"names": { # type: ignore
"integer": "number",
"real": "number",
"char": "string",
"text": "string",
"string": "string",
"boolean": "boolean",
"sequence": "array",
"set": "set",
"map": "object",
"nothing": "null",
"undefined": "undefined",
"int8": "number",
"uint8": "number",
"int16": "number",
"uint16": "number",
"int32": "number",
"uint32": "number",
"int64": "number",
"uint64": "number",
"bigint": "number",
"single_precision": "number",
"double_precision": "number",
"double_extended": "number",
"fixed_precision": "number",
"array": "array",
"list": "array",
"tuple": "array",
"any": "object",
"double_extended": "number",
"fixed_precision": "number",
"array": "array",
"list": "array",
"tuple": "array",
"any": "object",
},
"nested": ("<", ">"),
"nested": ("<", ">"),
"exception": "Error",
}


12 changes: 6 additions & 6 deletions tested/languages/typescript/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ def convert_value(value: Value) -> str:
result += "}"
return result
elif value.type in (
AdvancedNumericTypes.INT_64,
AdvancedNumericTypes.U_INT_64,
AdvancedNumericTypes.BIG_INT,
AdvancedNumericTypes.INT_64,
AdvancedNumericTypes.U_INT_64,
AdvancedNumericTypes.BIG_INT,
):
return f'BigInt("{value.data}")'
# Handle basic types
Expand Down Expand Up @@ -182,9 +182,9 @@ def _generate_internal_context(ctx: PreparedContext, pu: PreparedExecutionUnit)

# We need special code to make variables available outside of the try-catch block.
if (
not tc.testcase.is_main_testcase()
and isinstance(tc.input, PreparedTestcaseStatement)
and isinstance(tc.input.statement, VariableAssignment)
not tc.testcase.is_main_testcase()
and isinstance(tc.input, PreparedTestcaseStatement)
and isinstance(tc.input.statement, VariableAssignment)
):
result += f"let {tc.input.statement.variable}\n"

Expand Down
1 change: 0 additions & 1 deletion tests/test_linters.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def test_eslint(tmp_path: Path, config: dict, pytestconfig: pytest.Config):
config,
)
result = execute_config(conf)
print(conf)
updates = assert_valid_output(result, pytestconfig)
assert len(updates.find_all("annotate-code")) > 0

Expand Down

0 comments on commit 55bbfa1

Please sign in to comment.