diff --git a/README.md b/README.md index 6136b61..6bb6eb8 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ exit with a bad (non-zero) exit code. The default is `true`. The following command will lint all files in the current directory: ```shell -relint -c .relint.yml ** +relint -c .relint.yml FILE FILE2 ... ``` The default configuration file name is `.relint.yml` within your working diff --git a/relint/__main__.py b/relint/__main__.py index 739a754..afb162f 100644 --- a/relint/__main__.py +++ b/relint/__main__.py @@ -1,5 +1,4 @@ import argparse -import glob import subprocess # nosec import sys import warnings @@ -72,16 +71,11 @@ def main(args=None): print(f"relint: {__version__}") exit(0) - paths = { - path - for file in args.files - for path in glob.iglob(glob.escape(file), recursive=True) - } tests = list(load_config(args.config, args.fail_warnings, args.ignore_warnings)) matches = [] - for path in track(paths, description="Linting files..."): + for path in track(args.files, description="Linting files..."): matches.extend(lint_file(path, tests)) output = "" diff --git a/tests/test_main.py b/tests/test_main.py index 964af28..b8cfd80 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -11,7 +11,7 @@ def test_version(tmpdir, capsys): """Test that the version is correct.""" with tmpdir.as_cwd(): with pytest.raises(SystemExit) as exc_info: - main(["relint.py", "--version"]) + main(["--version"]) assert "0" in str(exc_info.value) assert f"relint: {relint.__version__}" in capsys.readouterr().out @@ -24,7 +24,7 @@ def test_main_execution(self, tmpdir, fixture_dir): tmpdir.join("dummy.py").write("# TODO do something") with tmpdir.as_cwd(): with pytest.raises(SystemExit) as exc_info: - main(["relint.py", "dummy.py"]) + main(["dummy.py"]) assert exc_info.value.code == 0 @@ -35,7 +35,7 @@ def test_main_execution_with_error(self, capsys, tmpdir, fixture_dir): tmpdir.join("dummy.py").write("# FIXME do something") with tmpdir.as_cwd(): with pytest.raises(SystemExit) as exc_info: - main(["relint.py", "dummy.py"]) + main(["dummy.py"]) out, _ = capsys.readouterr() assert "dummy.py:1" in out @@ -44,7 +44,7 @@ def test_main_execution_with_error(self, capsys, tmpdir, fixture_dir): assert "❱ 1 # FIXME do something" in out assert exc_info.value.code == 1 - @pytest.mark.parametrize("args", [tuple(), ("--summarize")]) + @pytest.mark.parametrize("args", [[], ["--summarize"]]) def test_main_execution_without_hint(self, args, capsys, tmpdir, fixture_dir): with (fixture_dir / ".relint.yml").open() as fs: config = fs.read() @@ -52,7 +52,7 @@ def test_main_execution_without_hint(self, args, capsys, tmpdir, fixture_dir): tmpdir.join("dummy.py").write("# hint: 🤐") with tmpdir.as_cwd(): with pytest.raises(SystemExit): - main(["relint.py", "dummy.py", *args]) + main(["dummy.py", *args]) out, _ = capsys.readouterr() assert "dummy.py:1" in out @@ -65,7 +65,7 @@ def test_raise_for_warnings(self, tmpdir, fixture_dir): tmpdir.join("dummy.py").write("# TODO do something") with tmpdir.as_cwd(): with pytest.raises(SystemExit) as exc_info: - main(["relint.py", "dummy.py", "-W"]) + main(["dummy.py", "-W"]) assert exc_info.value.code == 1 @@ -76,7 +76,7 @@ def test_ignore_warnings(self, tmpdir, fixture_dir): tmpdir.join("dummy.py").write("# TODO do something") with tmpdir.as_cwd(): with pytest.raises(SystemExit) as exc_info: - main(["relint.py", "dummy.py", "--ignore-warnings"]) + main(["dummy.py", "--ignore-warnings"]) assert exc_info.value.code == 0 @@ -87,7 +87,7 @@ def test_summarize(self, tmpdir, fixture_dir, capsys): tmpdir.join("dummy.py").write("# FIXME do something") with tmpdir.as_cwd(): with pytest.raises(SystemExit) as exc_info: - main(["relint.py", "dummy.py", "--summarize"]) + main(["dummy.py", "--summarize"]) out, _ = capsys.readouterr() assert "dummy.py:1" in out @@ -103,7 +103,7 @@ def test_code_padding_disabled(self, tmpdir, fixture_dir, capsys): tmpdir.join("dummy.py").write("# FIXME do something") with tmpdir.as_cwd(): with pytest.raises(SystemExit) as exc_info: - main(["relint.py", "dummy.py", "--code-padding=-1"]) + main(["dummy.py", "--code-padding=-1"]) out, _ = capsys.readouterr() assert "dummy.py:1" in out @@ -126,7 +126,7 @@ def test_main_execution_with_diff(self, capsys, mocker, tmpdir, fixture_dir): with tmpdir.as_cwd(): with pytest.raises(SystemExit) as exc_info: - main(["relint.py", "dummy.py", "--diff"]) + main(["dummy.py", "--diff"]) out, _ = capsys.readouterr() assert "Get it done right away!" in out diff --git a/tests/test_parse.py b/tests/test_parse.py index 02caaba..fb33d95 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -119,11 +119,12 @@ def test_parse_complete_diff(self): def test_empty_config_file(self, tmpdir): tmpdir.join(".relint.yml").write("") + tmpdir.join("dummy.py").write("") with tmpdir.as_cwd(): with warnings.catch_warnings(record=True) as w: with pytest.raises(SystemExit) as exc_info: - main(["**"]) + main(["dummy.py"]) assert exc_info.value.code == 0 assert issubclass(w[-1].category, UserWarning) @@ -160,7 +161,7 @@ def test_git_diff(self, capsys, tmpdir, fixture_dir): with tmpdir.as_cwd(): with pytest.raises(SystemExit) as exc_info: - main(["relint.py", "dummy.py", "--git-diff"]) + main(["dummy.py", "--git-diff"]) assert "0" in str(exc_info.value) @@ -174,5 +175,5 @@ def test_no_unicode(capsys, tmpdir, fixture_dir): tmpdir.join("test.png").write(png, mode="wb") with tmpdir.as_cwd(): with pytest.raises(SystemExit) as exc_info: - main(["relint.py", "test.png"]) + main(["test.png"]) assert "0" in str(exc_info.value)