From e00eee92e2714f80c908d812614d9f897fbbb50c Mon Sep 17 00:00:00 2001 From: Tobias Reiher Date: Tue, 15 Aug 2023 18:03:56 +0200 Subject: [PATCH] Enable checking of line length --- Makefile | 2 +- doc/language_reference/conf.py | 2 +- doc/user_guide/conf.py | 2 +- ide/gnatstudio/recordflux.py | 2 +- rflx/expression.py | 2 +- rflx/generator/session.py | 3 ++- rflx/ir.py | 6 ++++-- rflx/ls/lexer.py | 10 ++++++---- rflx/ls/model.py | 3 ++- tests/integration/cli_test.py | 7 ++++++- tests/unit/cli_test.py | 2 +- tests/unit/generator_test.py | 2 +- tests/unit/graph_test.py | 3 ++- tests/unit/specification/parser_test.py | 8 ++++---- 14 files changed, 33 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index fc24d704f..5f63b2298 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ VSIX ?= ide/vscode/recordflux.vsix GENERATED_DIR = generated BUILD_GENERATED_DIR := $(MAKEFILE_DIR)/$(BUILD_DIR)/$(GENERATED_DIR) PYTHON_PACKAGES = bin doc/language_reference/conf.py doc/user_guide/conf.py examples/apps ide language rflx tests tools stubs setup.py -DEVUTILS_HEAD = ee74c35d71f4153aa58ab2b7efc8342c97d8ce31 +DEVUTILS_HEAD = 838aa808eab2ca88799182875934376f4c77dcfc GNATCOLL_HEAD = 25459f07a2e96eb0f28dcfd5b03febcb72930987 LANGKIT_HEAD = 65e2dab678b2606e3b0eada64b7ef4fd8cae91bb ADASAT_HEAD = f948e2271aec51f9313fa41ff3c00230a483f9e8 diff --git a/doc/language_reference/conf.py b/doc/language_reference/conf.py index 766bf1db4..cf89967e5 100644 --- a/doc/language_reference/conf.py +++ b/doc/language_reference/conf.py @@ -66,7 +66,7 @@ - """, + """, # noqa: E501 "class": "", }, ], diff --git a/doc/user_guide/conf.py b/doc/user_guide/conf.py index a970c39aa..5c2493e14 100644 --- a/doc/user_guide/conf.py +++ b/doc/user_guide/conf.py @@ -66,7 +66,7 @@ - """, + """, # noqa: E501 "class": "", }, ], diff --git a/ide/gnatstudio/recordflux.py b/ide/gnatstudio/recordflux.py index 270b066f3..799472a17 100644 --- a/ide/gnatstudio/recordflux.py +++ b/ide/gnatstudio/recordflux.py @@ -146,7 +146,7 @@ -""" +""" # noqa: E501 GPS.parse_xml(XML) diff --git a/rflx/expression.py b/rflx/expression.py index 8840d2a8e..3aae93249 100644 --- a/rflx/expression.py +++ b/rflx/expression.py @@ -3735,7 +3735,7 @@ def to_ir(self, variable_id: Generator[ID, None, None]) -> ir.ComplexExpr: for choice, expr in self.choices: e_stmts, e_expr = _to_ir_basic_expr(expr, variable_id) - # TODO(eng/recordflux/RecordFlux#633): Add check for unsupported case expressions to model + # TODO(eng/recordflux/RecordFlux#633): Check for unsupported case expressions in model assert not e_stmts cs: list[ir.BasicExpr] if isinstance(self.expr.type_, rty.Enumeration): diff --git a/rflx/generator/session.py b/rflx/generator/session.py index 80ef90205..0524b5255 100644 --- a/rflx/generator/session.py +++ b/rflx/generator/session.py @@ -2422,7 +2422,8 @@ def _assign_to_field_access( ) fatal_fail( - f'unexpected type ({field_access.type_}) for "{field_access}" in assignment of "{target}"', + f'unexpected type ({field_access.type_}) for "{field_access}"' + f' in assignment of "{target}"', Subsystem.GENERATOR, location=target.location, ) diff --git a/rflx/ir.py b/rflx/ir.py index 3d471a7d8..867a75454 100644 --- a/rflx/ir.py +++ b/rflx/ir.py @@ -1206,7 +1206,8 @@ def substituted(self, mapping: Mapping[ID, ID]) -> IntCall: ) def to_z3_expr(self) -> z3.ArithRef: - # TODO(eng/recordflux/RecordFlux#1338): Return value need not to be identical for identical arguments + # TODO(eng/recordflux/RecordFlux#1338): Return value need not to be identical + # The return value may be different even if the arguments are the same. expression = z3.Int(str(self.identifier)) return -expression if self.negative else expression @@ -1229,7 +1230,8 @@ def substituted(self, mapping: Mapping[ID, ID]) -> BoolCall: ) def to_z3_expr(self) -> z3.BoolRef: - # TODO(eng/recordflux/RecordFlux#1338): Return value need not to be identical for identical arguments + # TODO(eng/recordflux/RecordFlux#1338): Return value need not to be identical + # The return value may be different even if the arguments are the same. return z3.Bool(str(self.identifier)) diff --git a/rflx/ls/lexer.py b/rflx/ls/lexer.py index c142797b9..e4ce386e5 100644 --- a/rflx/ls/lexer.py +++ b/rflx/ls/lexer.py @@ -21,8 +21,10 @@ class Token: ---------- symbol: The symbol referenced by this token. lexeme: A string representation of the token in the file. - line_number: An integer indicating the line at which the token is located in the file starting from 1. - character_offset: An integer indicating the character offset from the begining of the line at which the first character of the lexeme is located starting from 1. + line_number: An integer indicating the line at which the token is located in the file + starting from 1. + character_offset: An integer indicating the character offset from the begining of the line + at which the first character of the lexeme is located starting from 1. """ symbol: Optional[Symbol] @@ -52,7 +54,7 @@ def tokens(self) -> list[Token]: return self._tokens def search_token(self, line_number: int, character_offset: int) -> Optional[Token]: - """Return the token located at (line_numer, character_offset) if it exists, otherwise return None.""" + """Return the token at the given location if it exists, otherwise return None.""" if len(self._tokens) == 0: return None @@ -98,7 +100,7 @@ def search_token(self, line_number: int, character_offset: int) -> Optional[Toke return None def tokenize(self, source: str, path: str = "") -> None: - """Take a source string and turn it into a list of tokens accessible via the LSLexer.tokens() method.""" + """Convert a string into a list of tokens that can be accessed via the tokens property.""" unit = rflx_lang.AnalysisContext().get_from_buffer( path, diff --git a/rflx/ls/model.py b/rflx/ls/model.py index 3db1292d5..a1277bb3c 100644 --- a/rflx/ls/model.py +++ b/rflx/ls/model.py @@ -75,7 +75,8 @@ class Symbol: Arguments: --------- identifier: The unique identifier associated to the symbol. - category: A SymbolCategory indicating the type (message, session, numeric, enumeration...) of the symbol. + category: A SymbolCategory indicating the type (message, session, numeric, enumeration...) + of the symbol. definition_location: A Location indicating where the symbol is defined. parent: A optional ID indicating if the cur """ diff --git a/tests/integration/cli_test.py b/tests/integration/cli_test.py index 6be53c906..c9c6e9272 100644 --- a/tests/integration/cli_test.py +++ b/tests/integration/cli_test.py @@ -52,6 +52,11 @@ def test_parse_no_subsequent_errors_caused_by_style_errors(tmp_path: Path) -> No with pytest.raises( RecordFluxError, - match=rf"^{a}:12:0: style: error: unexpected keyword indentation \(expected 3, 12 or 15\) \[indentation\]$", + match=( + r"^" + rf"{a}:12:0: style: error: unexpected keyword indentation \(expected 3, 12 or 15\)" + r" \[indentation\]" + r"$" + ), ): cli.parse([a]) diff --git a/tests/unit/cli_test.py b/tests/unit/cli_test.py index 1f07afc7a..d4039affb 100644 --- a/tests/unit/cli_test.py +++ b/tests/unit/cli_test.py @@ -214,7 +214,7 @@ def generator_mock( monkeypatch.setattr( generator.Generator, "generate", - lambda self, model, integration, directory, library_files, top_level_package: None, # noqa: ARG005 + lambda self, model, integration, directory, library_files, top_level_package: None, # noqa: ARG005, E501 ) assert ( cli.main( diff --git a/tests/unit/generator_test.py b/tests/unit/generator_test.py index ce1bef5c9..a49d6ec13 100644 --- a/tests/unit/generator_test.py +++ b/tests/unit/generator_test.py @@ -1162,7 +1162,7 @@ def _update_str(self) -> None: pragma Finalization; goto Finalize_S; end if;\ -""", +""", # noqa: E501 ), ( ir.Assign( diff --git a/tests/unit/graph_test.py b/tests/unit/graph_test.py index d767ac257..e407ff3cc 100644 --- a/tests/unit/graph_test.py +++ b/tests/unit/graph_test.py @@ -118,7 +118,8 @@ def test_dot_graph_with_condition(tmp_path: Path) -> None: ) expected = """ digraph "P::M" { - graph [bgcolor="#00000000", pad="0.1", ranksep="0.1 equally", splines=true, truecolor=true]; + graph [bgcolor="#00000000", pad="0.1", ranksep="0.1 equally", splines=true, + truecolor=true]; edge [color="#6f6f6f", fontcolor="#6f6f6f", fontname="Fira Code", penwidth="2.5"]; node [color="#6f6f6f", fillcolor="#009641", fontcolor="#ffffff", fontname=Arimo, shape=box, style="rounded,filled", width="1.5"]; diff --git a/tests/unit/specification/parser_test.py b/tests/unit/specification/parser_test.py index a66682570..1e243f22b 100644 --- a/tests/unit/specification/parser_test.py +++ b/tests/unit/specification/parser_test.py @@ -1457,7 +1457,7 @@ def test_parse_ethernet_spec() -> None: "_kind": "ID", "name": { "_kind": "UnqualifiedID", - "_value": "Type_Length_TPID", + "_value": "Type_Length_TPID", # noqa: E501 }, "package": None, }, @@ -1510,7 +1510,7 @@ def test_parse_ethernet_spec() -> None: "_kind": "ID", "name": { "_kind": "UnqualifiedID", - "_value": "Type_Length_TPID", + "_value": "Type_Length_TPID", # noqa: E501 }, "package": None, }, @@ -1718,7 +1718,7 @@ def test_parse_ethernet_spec() -> None: "identifier": { "_kind": "ID", "name": { - "_kind": "UnqualifiedID", + "_kind": "UnqualifiedID", # noqa: E501 "_value": "Payload", }, "package": None, @@ -1756,7 +1756,7 @@ def test_parse_ethernet_spec() -> None: "identifier": { "_kind": "ID", "name": { - "_kind": "UnqualifiedID", + "_kind": "UnqualifiedID", # noqa: E501 "_value": "Payload", }, "package": None,