Skip to content

Replace strictyaml with PyYAML - #4548

Merged
kevinjqliu merged 3 commits into
apache:mainfrom
Anurag-S1ngh:chore/4502-replace-strictyaml
Dec 1, 2026
Merged

kevinjqliu merged 3 commits into
apache:mainfrom
Anurag-S1ngh:chore/4502-replace-strictyaml

Conversation

@Anurag-S1ngh

Copy link
Copy Markdown
Contributor

Closes #4502

Rationale for this change

strictyaml has not had a release since March 2023 and vendors an outdated copy of ruamel.yaml. PyIceberg only calls strictyaml.load(yml_str).data without a schema, which keeps every scalar as a string.

Replace it with PyYAML's BaseLoader. BaseLoader also keeps every scalar as a string, so .pyiceberg.yaml values such as 4, yes, and 1.0 are still returned as strings and Config.get_int/get_bool keep their current behavior.

uv lock regenerates the lockfile and removes strictyaml.

Are these changes tested?

  • pytest tests/utils/test_config.py (21 passed)
  • ruff check and ruff format --check on the changed files
  • Added a test that parses unquoted numbers and boolean-like strings from the config file

Are there any user-facing changes?

The strictyaml dependency is replaced by pyyaml. Configuration file parsing behavior is unchanged.

Anurag-S1ngh and others added 3 commits December 2, 2026 00:07
strictyaml is no longer maintained. BaseLoader keeps every scalar as a string, which matches how .pyiceberg.yaml is parsed today.
The yaml import needs types-PyYAML in the pre-commit mypy environment.
- Use yaml.CBaseLoader with yaml.BaseLoader fallback when loading
  .pyiceberg.yaml since Config() is instantiated across runtime paths.
- Cover NO, null, ~, empty values, and ISO dates in scalar-preservation
  config tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kevinjqliu

Copy link
Copy Markdown
Contributor

thanks for putting this together @Anurag-S1ngh! pushed a small commit on top to:

  • use CBaseLoader with a BaseLoader fallback (same scalar/safety behavior, ~9x faster since Config() gets called across runtime paths)
  • expand the scalar test to also cover NO, null, ~, empty values, and dates

@kevinjqliu kevinjqliu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! good cleanup to drop an unmaintained dep.

for the record on behavior diffs vs strictyaml:

  • all scalars still stay strings (4, 1.0, yes/no/NO, null/~, empty values, dates) and !!python/... tags remain safe (no constructors registered)
  • duplicate keys now silently take the last value instead of raising, flow style and anchors are accepted (<<: merge keys stay literal keys), and bad YAML raises yaml.YAMLError instead of strictyaml errors

@kevinjqliu
kevinjqliu enabled auto-merge December 1, 2026 20:29
@kevinjqliu
kevinjqliu added this pull request to the merge queue Dec 1, 2026
Merged via the queue into apache:main with commit 1960c0d Dec 1, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace unmaintained strictyaml dependency with ruamel.yaml or PyYAML

2 participants