Skip to content

Commit

Permalink
fixed all files and added pylint to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
BayerC authored and martis42 committed Apr 9, 2022
1 parent 370d39c commit 08c55c4
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
- run: pip install poetry
- run: poetry install
- name: Coverage
run: poetry run pytest --cov
run: poetry run pytest --cov --pylint
11 changes: 0 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,3 @@ repos:
args: [ --py38-plus ]
language: system
types: [ python ]

- id: pylint
name: pylint
entry: poetry run pylint ./src
language: system
types: [ python ]
args:
[
"-rn", # Only display messages
"-sn", # Don't display the score
]
19 changes: 18 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ pyupgrade = "^2.31.1"
coverage = {extras = ["toml"], version = "^6.3.2"}
pytest-cov = "^3.0.0"
pylint = "^2.13.5"
pytest-pylint = "^0.18.0"

[tool.pylint.FORMAT]
max-line-length = 120

disable = ["missing-function-docstring",
"missing-module-docstring",
"missing-class-docstring"]
"missing-class-docstring",
"too-many-branches", "import-error"]

[tool.pylint.SIMILARITIES]
ignore-imports=true

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
4 changes: 2 additions & 2 deletions src/parse_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def filter_includes(includes: List[Include], ignored_includes: set) -> List[Incl
def get_relevant_includes_from_files(files: Union[List[str], None], ignored_includes: set) -> List[Include]:
all_includes = []
if files:
for f in files:
includes = get_includes_from_file(Path(f))
for file in files:
includes = get_includes_from_file(Path(file))
all_includes.extend(includes)
return filter_includes(includes=all_includes, ignored_includes=ignored_includes)
22 changes: 12 additions & 10 deletions test/execute_tests_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class TestCmd:
@dataclass
class ExpectedResult:
"""
Encapsulates an expected result of a DWYU analysis and offers functions to compare a given output to the expectations.
Encapsulates an expected result of a DWYU analysis and offers functions
to compare a given output to the expectations.
"""

success: bool
Expand Down Expand Up @@ -136,10 +137,10 @@ def verify_test(test: TestCase, process: sb.CompletedProcess, verbose: bool) ->
ok_verb = "succeeded" if test.expected.success else "failed"
print(f"<<< OK '{test.name}' {ok_verb} as expected")
return True
else:
print("\n" + process.stdout + "\n")
print(f"<<< ERROR '{test.name}' did not behave as expected")
return False

print("\n" + process.stdout + "\n")
print(f"<<< ERROR '{test.name}' did not behave as expected")
return False


def make_cmd(test_cmd: TestCmd, extra_args: List[str]) -> List[str]:
Expand Down Expand Up @@ -186,15 +187,16 @@ def execute_tests(
if not is_compatible_version(version=version, compatible_versions=test.compatible_versions):
print(f"\n--- Skip '{test.name}' due to incompatible Bazel '{version}'")
continue
else:
print(f"\n>>> Execute '{test.name}' with Bazel '{version}'")

print(f"\n>>> Execute '{test.name}' with Bazel '{version}'")

process = sb.run(
make_cmd(test_cmd=test.cmd, extra_args=extra_args),
env=test_env,
text=True,
stdout=sb.PIPE,
stderr=sb.STDOUT,
check=False,
)

if not verify_test(test=test, process=process, verbose=verbose):
Expand Down Expand Up @@ -229,6 +231,6 @@ def main(args: argparse.Namespace, test_cases: List[TestCase], test_versions: Li
print("These tests failed:")
print("\n".join(f"- '{t.name} - for Bazel version '{t.version}'" for t in failed_tests))
return 1
else:
print("SUCCESS\n")
return 0

print("SUCCESS\n")
return 0
2 changes: 1 addition & 1 deletion test/execute_tests_utest.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def test_with_aspect(self):
cmd = make_cmd(test_cmd=TestCmd(target="//foo:bar"), extra_args=[])
self.assertEqual(cmd, self._base_cmd() + ["--", "//foo:bar"])

def test_with_aspect(self):
def test_with_aspect_2(self):
cmd = make_cmd(test_cmd=TestCmd(target="//foo:bar", aspect="//some/aspect.bzl"), extra_args=[])
self.assertEqual(
cmd,
Expand Down

0 comments on commit 08c55c4

Please sign in to comment.