Settings¶
Settings is an immutable dataclass that controls the formatting behavior. It can be constructed directly, loaded from pyproject.toml, or created from a dictionary.
Class Reference¶
behave_format.config.settings.Settings
dataclass
¶
Immutable formatter settings.
Attributes:
| Name | Type | Description |
|---|---|---|
indent |
int
|
Number of spaces for indentation (default 2). |
sort_tags |
bool
|
Sort tags alphabetically (default True). |
sort_features |
bool
|
Sort features by name (default False). |
sort_scenarios |
bool
|
Sort scenarios by name (default False). |
line_length |
int
|
Maximum line length for reference (default 120). |
Source code in behave_format/config/settings.py
from_pyproject
classmethod
¶
Load settings from a pyproject.toml file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to the |
'pyproject.toml'
|
Returns:
| Type | Description |
|---|---|
Settings
|
A Settings instance. If the file or section is missing, |
Settings
|
defaults are returned. |
Source code in behave_format/config/settings.py
from_dict
classmethod
¶
Create settings from a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
Dictionary with optional keys: indent, sort_tags, sort_features, sort_scenarios, line_length. |
required |
Returns:
| Type | Description |
|---|---|
Settings
|
A Settings instance. |
Source code in behave_format/config/settings.py
Configuration Options¶
| Option | Type | Default | Description |
|---|---|---|---|
indent |
int |
2 |
Number of spaces for indentation. |
sort_tags |
bool |
True |
Sort tags alphabetically. |
sort_features |
bool |
False |
Sort features by name. |
sort_scenarios |
bool |
False |
Sort scenarios by name. |
line_length |
int |
120 |
Maximum line length for reference. |
Loading from pyproject.toml¶
The [tool.behave-format] section in pyproject.toml:
[tool.behave-format]
indent = 4
sort_tags = true
sort_features = false
sort_scenarios = false
line_length = 120
Creating from a Dictionary¶
Immutability¶
Settings is a frozen dataclass. Once created, its attributes cannot be modified: