Commit 9c92f22
Fix mypy section-name validation type
The Python package workflow failed in the Ubuntu Python 3.14 job while running mypy. The error reported that GitConfigParser.add_section() may receive configparser's _SectionName type, which is `str | _UNNAMED_SECTION`, but _assure_config_name_safe() accepted only `str`.
Keep the runtime validation unchanged for normal string section and option names, but type the guard for configparser section names and only apply the unsafe-character regex to strings. This preserves compatibility with configparser's section-name type while still rejecting CR, LF, and NUL in real names.
Validation:
- uv run --with gitdb --with mypy --with pytest --with pytest-cov --with ddt --with pytest-mock --with pytest-instafail --with pytest-sugar --with pre-commit mypy --python-version=3.14
- uv run --with gitdb --with pytest --with pytest-cov --with ddt --with pytest-mock --with pytest-instafail --with pytest-sugar python -m pytest test/test_config.py::TestBase::test_set_value_rejects_unsafe_section_and_option_names --no-cov
- uv run --with ruff ruff check git/config.py1 parent e226e42 commit 9c92f22
1 file changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
892 | 892 | | |
893 | 893 | | |
894 | 894 | | |
895 | | - | |
896 | | - | |
| 895 | + | |
| 896 | + | |
897 | 897 | | |
898 | 898 | | |
899 | 899 | | |
| |||
0 commit comments