Config Files¶
Use configuration files to manage Pyreload settings across your projects.
Configuration File Formats¶
Pyreload supports multiple formats:
- YAML (
.yml,.yaml) - JSON (
.json) - TOML (
.toml)
Default Locations¶
Pyreload automatically searches for config files in this order:
.pyreload.yml.pyreload.yaml.pyreload.json.pyreload.tomlpyreload.ymlpyreload.yamlpyreload.jsonpyreload.toml
Configuration Options¶
YAML Format¶
# Watch paths
watch:
- src
- config
- tests
# File extensions to watch
extensions:
- py
- yaml
- json
# Patterns to ignore
ignore:
- "**/__pycache__/**"
- "**/*.pyc"
- ".git/**"
# Use polling instead of native file watching
polling: false
# Polling interval in seconds (if polling is true)
poll_interval: 1.0
# Verbose output
verbose: false
# Enable exec mode (replace process instead of spawning)
exec: false
# Clean mode (clear screen on restart)
clean: false
# Delay before restarting (in seconds)
delay: 1.0
JSON Format¶
{
"watch": ["src", "config"],
"extensions": ["py", "yaml"],
"ignore": ["**/__pycache__/**", "**/*.pyc"],
"polling": false,
"verbose": false,
"exec": false,
"clean": false,
"delay": 1.0
}
TOML Format¶
watch = ["src", "config"]
extensions = ["py", "yaml"]
ignore = ["**/__pycache__/**", "**/*.pyc"]
polling = false
verbose = false
exec = false
clean = false
delay = 1.0
Using Config Files¶
Automatic Discovery¶
Place a config file in your project root:
Explicit Config¶
Specify a config file:
Override Config Options¶
Command-line options override config file settings:
Complete Example¶
Project Structure¶
myproject/
├── .pyreload.yml
├── src/
│ └── app.py
├── config/
│ └── settings.yaml
└── tests/
└── test_app.py
.pyreload.yml¶
watch:
- src
- config
extensions:
- py
- yaml
ignore:
- "tests/**"
- "**/__pycache__/**"
- "**/*.pyc"
- ".pytest_cache/**"
clean: true
delay: 0.5
verbose: false
Running¶
Environment-Specific Configs¶
Development¶
Production¶
Usage¶
# Development
pyreload -c .pyreload.dev.yml app.py
# Production
pyreload -c .pyreload.prod.yml app.py
Best Practices¶
- Use version control: Commit config files to share settings
- Environment files: Create separate configs for dev/prod
- Document settings: Add comments explaining non-obvious options
- Start simple: Begin with basic settings and expand as needed
Config Validation¶
Pyreload validates config files and reports errors:
pyreload -c invalid.yml app.py
# Error: Invalid configuration: unknown option 'watches' (did you mean 'watch'?)