Skip to content

Redo validation#74

Merged
honnibal merged 65 commits intomainfrom
redo-validation
Mar 22, 2026
Merged

Redo validation#74
honnibal merged 65 commits intomainfrom
redo-validation

Conversation

@honnibal
Copy link
Copy Markdown
Member

@honnibal honnibal commented Mar 22, 2026

Couldn't bear to abandon the refactor and go back to the tangled v0.1.5 implementation. I redid the type checking, laying out a good top-level structure for the recursion: https://github.com/explosion/confection/blob/87fb1733317208ffa1929b895119f315d93f0e6b/confection/typechecker.py. This allowed me to finally separate the ConfigParser part out into two pure functions that just handle the string-to-dict and dict-to-string parts.

honnibal added 30 commits March 22, 2026 08:51
- Fix fill_config returning undefined 'defaulted' instead of 'overrided'
- Add missing imports: warnings, Dict, List in _interpolation.py
- Replace srsly.json_loads/json_dumps with stdlib json in util.py
- Add missing ConfigValidationError import in util.py
- Create _constants.py module for shared constants (VARIABLE_RE,
  SECTION_PREFIX, ARGS_FIELD, etc.) to avoid circular imports
- Fix __init__.py importing symbols from wrong modules
- Phase 1: use sections() not keys() to exclude DEFAULT
- Phase 2: navigate into section (parts not parts[:-1])
- _replace_section_refs: write to node[key] not config[key]
- validate_configparser: validate configparser structure early
- test_config_basic: hypothesis roundtrip test with interpolate=False
honnibal added 29 commits March 22, 2026 14:36
Cover: custom handlers, Strict() metadata, string forward refs, string enums,
dataclass decompose, Parameter.empty, pydantic v1/v2 validator edges,
schema alias decompose
- fill_config now recursively fills defaults from registered function schemas
- Handles nested promises (promise args that are themselves promises)
- Schema.from_function() generates schemas from function signatures
Cover: Promise lifecycle, insert/resolve/fix_positionals, registry.has/get,
get_constructor, parse_args, alias_generator, _deep_copy_with_uncopyable,
_is_config_section, nested promise resolution
…inst unresolved types

Fixes TypeError when TypeVar bounds or generic origins contain ForwardRefs
or complex Union types that aren't valid for isinstance(). Falls back to
outer_match() for recursive checking.
ForwardRefs from dataclass/typing annotations (e.g. thinc's Floats3d)
can reach the typechecker when not using pydantic for resolution.
Accept them since we can't validate what we can't resolve.
Instead of accepting unresolved ForwardRefs blindly, resolve them using
get_type_hints() with the dataclass's module namespace. Falls back to
raw annotations if resolution fails.
… compat

- resolve() accepts schema and validate kwargs
- fill() accepts schema for default filling
- Post-resolve validation against schema when validate=True
- Note: promise arg validation not yet implemented (1 spaCy test fails)
…igparser level

Overrides now applied in the correct order:
1. Parse flat sections (configparser)
2. Re-nest into dict (interpret)
3. Apply overrides (on nested dict)
4. Replace section refs

Fixes dict overrides replacing promise sections (e.g. replacing a scorer
with a different registered function).
- fill() skips promises referencing unknown functions (defaults can't be
  filled, error surfaces at resolve time)
- fill_defaults() strips extra fields when schema has extra='forbid'
- Recursive default filling for nested schemas
- #52: Create configparser sections for * paths with leaf values in to_str
- #58/#59: Coerce dict args to BaseModel instances when function expects them
- #61: Detect self-referencing interpolation variables as section refs
@honnibal honnibal merged commit 7552b0d into main Mar 22, 2026
16 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.

1 participant