Skip to content

TypeError: 'NoneType' object is not iterable #274

@mgedmin

Description

@mgedmin

I noticed that my vim stopped highlighting YAML syntax errors. I ran yamllint directly on a file I was editing and saw

Traceback (most recent call last):
  File "/home/mg/.local/bin/yamllint", line 8, in <module>
    sys.exit(run())
  File "/home/mg/.local/pipx/venvs/yamllint/lib/python3.8/site-packages/yamllint/cli.py", line 168, in run
    conf = YamlLintConfig(file=user_global_config)
  File "/home/mg/.local/pipx/venvs/yamllint/lib/python3.8/site-packages/yamllint/config.py", line 42, in __init__
    self.parse(content)
  File "/home/mg/.local/pipx/venvs/yamllint/lib/python3.8/site-packages/yamllint/config.py", line 83, in parse
    for rule in self.rules:
TypeError: 'NoneType' object is not iterable

Turns out this was caused by my ~/.config/yamllint/config containing

extends: relaxed
rules:
line-length:
  max: 200

I'm pretty sure this used to work before I did some pip upgrades.

I fixed my problem by changing the config to explicitly set rules: [], but I wonder if you'd want to catch this kind of type error in the YAML config and produce better error messages? Or even allow null values and treat them as empty lists/dicts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions