Skip to content

Commit

Permalink
Add deactivation of line-length check in specification generation
Browse files Browse the repository at this point in the history
Ref. #1079
  • Loading branch information
treiher committed Jun 21, 2022
1 parent 1d04f39 commit 25f708f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rflx/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ def create_specifications(self) -> Dict[ID, str]:
def write_specification_files(self, output_dir: Path) -> None:
"""Write corresponding specification files (one per package) into given directory."""
for package, specification in self.create_specifications().items():
(output_dir / f"{package.flat.lower()}.rflx").write_text(specification)
header = (
"-- style: disable = line-length\n\n"
if any(len(l) > 120 for l in specification.split("\n"))
else ""
)
(output_dir / f"{package.flat.lower()}.rflx").write_text(f"{header}{specification}")

def _add_missing_types_and_validate(self) -> None:
error = self._check_duplicates()
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/model/model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,11 @@ def test_write_specification_file_multiple_packages_missing_deps(tmp_path: Path)
end R;"""
)


def test_write_specification_files_line_too_long(tmp_path: Path) -> None:
t = ModularInteger("P::" + "T" * 120, Number(256))
Model([t]).write_specification_files(tmp_path)
expected_path = tmp_path / Path("p.rflx")
assert list(tmp_path.glob("*.rflx")) == [expected_path]
assert expected_path.read_text().startswith("-- style: disable = line-length\n\npackage P is")

0 comments on commit 25f708f

Please sign in to comment.