Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on empty configuration #24

Closed
kwavnet opened this issue Aug 2, 2022 · 6 comments
Closed

Crash on empty configuration #24

kwavnet opened this issue Aug 2, 2022 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@kwavnet
Copy link

kwavnet commented Aug 2, 2022

Traceback (most recent call last):
  File "/path/bin/relint", line 8, in <module>
    sys.exit(main())
  File "/path/lib/python3.8/site-packages/relint.py", line 220, in main
    tests = list(load_config(args.config))
  File "/path/lib/python3.8/site-packages/relint.py", line 60, in load_config
    for test in yaml.safe_load(fs):
TypeError: 'NoneType' object is not iterable

Reproduction:

  • create an empty file relint.yaml
  • run with relint -c relint.yaml
@codingjoe codingjoe added the bug Something isn't working label Aug 3, 2022
@codingjoe codingjoe self-assigned this Aug 3, 2022
@codingjoe
Copy link
Owner

Hi @witekio-kwe,

Thanks for reaching out. Yes, we expect the YAML to be a list. I believe we should output a human-readable error message.

I'll whip up something.

Cheers,
Joe

@codingjoe
Copy link
Owner

@witekio-kwe would you be so kind as to review #25? I'd just want to make sure that this will improve upon the issue you reported.

@kwavnet
Copy link
Author

kwavnet commented Aug 3, 2022

@codingjoe the better error message are a very nice improvement - thx for that.
But still it doesn't actually solve my problem.

We have a multi repository structure and using pre-commit in each of them, where relint is a integral part of it.
But for one of the many repository, we need to have no rules in this file, while all the other repos do have at least one rule.
I kind of helped myself with creating a dummy rule for this particular repo, but that doesn't look well IMO.
From my perspective I'd expect that relint just returns with exit code 0 if there are no rules configured - currently I will always get a non zero code in this special case

@codingjoe
Copy link
Owner

Aaah, I see. Interesting use case. I won't exit with an error, but emit a UserWarning instead. That won't result in a non-zero exit code, but still is verbose enough to suggest changes.

@kwavnet
Copy link
Author

kwavnet commented Aug 3, 2022

Aaah, I see. Interesting use case. I won't exit with an error, but emit a UserWarning instead. That won't result in a non-zero exit code, but still is verbose enough to suggest changes.

ok, that would ofc work for me as well

@codingjoe
Copy link
Owner

@witekio-kwe release 1.3.2 ships with your fix :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants