Skip to content

Modernisation - #181

Draft
timsavage wants to merge 8 commits into
mainfrom
modernisation
Draft

timsavage wants to merge 8 commits into
mainfrom
modernisation

Conversation

@timsavage

Copy link
Copy Markdown
Member

Updates to odin to improve typing, performance and any bugs discovered by an automated review

Replace the custom cached_property implementation with functools.cached_property,
updating clear_caches to a standalone clear_cached_properties helper. Refactor
chunk to use itertools.islice with input validation. Clean up related _cache
workarounds in adapters and resources.
Add __bool__, __len__, __contains__, __getitem__, __iter__, and
__enter__/__exit__ to ValidationErrorCollection so it behaves like a
mapping and can be used as a context manager that raises on exit. Add
helpers add_error, clear, and message_count, and guard add_message and
add_resource_message against empty inputs. Type-annotate the class and
move the BaseField import behind TYPE_CHECKING. Expand tests to cover
all new methods and edge cases.
Add full type annotations, __all__ exports, and docstrings throughout
registration.py. Support isolated instances via shared=False to enable
deterministic testing. Change field_resolvers from a set to a sorted list
so subclass resolvers take precedence by MRO depth. Add clear() and
invalidate child-resource cache on new registrations. Improve
get_validation_error_handler to accept both exception instances and
classes. Add comprehensive tests for all cache methods and module-level
aliases.
…dator

Add full type annotations, __all__ exports, and __slots__ throughout
validators.py. Replace custom IPv4/IPv6 regex validation with
ipaddress stdlib. Add BetweenValidator for range checks. Support
inverse_match on RegexValidator and decorator usage for
simple_validator. Enforce RFC 5321 email length limits (254 total, 64
user, 255 domain). Rewrite tests to follow Arrange, Act, Assert pattern
with pytest.raises context managers.
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