Skip to content

Commit

Permalink
Drop broken globbing support
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjoe committed Mar 24, 2024
1 parent fe98aea commit 762484f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions relint/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import argparse
import glob
import subprocess # nosec
import sys
import warnings
Expand Down Expand Up @@ -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 = ""
Expand Down
20 changes: 10 additions & 10 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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
Expand All @@ -44,15 +44,15 @@ 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()
tmpdir.join(".relint.yml").write(config)
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
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions tests/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand All @@ -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)

0 comments on commit 762484f

Please sign in to comment.