Troubleshooting¶
IDE Not Showing Autocomplete¶
Symptoms: - No autocomplete for config attributes - IDE doesn't recognize config structure
Solutions:
- Ensure the
.pyifile exists next to yourload_config.py - Reload your IDE/editor window
- Check that your language server is running (VSCode: check Python extension)
- For PyCharm:
File→Invalidate Caches→Restart
Config Object is Immutable¶
Error:
Cause: Config is frozen by default (immutable dataclass).
Solutions:
Option 1: Use mutate_config() helper (recommended)
from heracless import mutate_config
config = load_config()
new_config = mutate_config(config, "database.host", "new-host")
Option 2: Load with frozen=False (not recommended for production)
YAML Parsing Errors¶
Error:
heracless.utils.exceptions.YamlSyntaxError: Syntax Error in your YAML File:
mapping values are not allowed in this context (line 3, column 8)
Cause: Invalid YAML syntax in config file. The message includes the line and column of the problem.
Solution: Validate your YAML:
Common issues: - Incorrect indentation - Missing colons - Invalid characters - Mixing tabs and spaces
YamlSyntaxError is also raised for YAML that heracless doesn't support:
- More than one document in a file (separated by ---)
- Custom or unsupported tags such as !!python/object or !!binary
- Nesting deeper than 128 levels, or aliases expanding to more than 1,000,000 nodes
ConfigError¶
Error:
heracless.utils.exceptions.ConfigError: the top level of a config file must be a mapping of keys to values, found a sequence
Cause: The top level of the YAML file is a list or a single value instead of a mapping.
Solution: Put your settings under keys at the top level of the file.
Config Is None¶
Cause: The config file is empty or only contains comments. load_config() returns None in that case and no stub is written.
Solution: Add your settings to the file.
DirectoryError / FileNotFoundError¶
Error:
Cause: The config file doesn't exist, or the directory the stub should be written to doesn't exist. DirectoryError is a subclass of FileNotFoundError, so except FileNotFoundError catches it too. Heracless does not create a missing config file.
Solutions:
- Check the path in
CONFIG_YAML_PATHis correct - Use absolute paths or
Path(__file__)for relative paths: - Verify the config file exists:
Type Checking Not Working¶
Symptoms: - mypy doesn't catch config typos - No type errors for invalid attribute access
Solutions:
- Ensure
.pyistub file is generated (setstub_dump=True) - Run mypy with correct configuration:
- Check mypy is using the correct Python version:
Stub File Not Generated¶
Cause: stub_dump=False or file_path=None
Solution:
def load_config(..., stub_dump: bool = True) -> Config:
file_path = Path(__file__).resolve() if stub_dump else None
return _load_config(config_path, file_path, frozen=frozen)
Ensure stub_dump=True (default).
Still Having Issues?¶
If you encounter other problems:
- Check the GitHub Issues
- Open a new issue with:
- Heracless version (
pip show heracless) - Python version
- Operating system
- Minimal reproducible example
- Expected vs actual behavior