Skip to content

v1.6.0 - Standardise Type Safety, Simplify Overloads, and Enhance Documentation

Latest

Choose a tag to compare

@chrimaho chrimaho released this 02 Jan 22:54

📋 Summary

Standardise the type hinting system across the entire library, transitioning from custom type aliases to native Python typing constructs. Simplify complex function overloads in the checkers.py and output.py modules, improve the robustness of type checking logic, and expand the documentation for core utility classes.

🛡️ Type Safety & Standardisation

  • Native Typing: Replace custom type aliases like any_collection, str_collection, and scalar with standard library types such as Collection[Any], Collection[str], and Any.
  • Explicit Callables: Add explicit Callable[..., bool] and Callable[..., None] type annotations to function aliases in the checkers.py module for improved static analysis.
  • Generic Collections: Refactor internal logic to use Collection[type] instead of specific list or tuple types, allowing for more flexible input handling.
  • List Standardisation: Update all __all__ export lists and internal string lists to use the native list[str] type.

⚙️ Logic & Overload Simplification

  • Overload Consolidation: Reduce the number of @overload definitions for is_all_values_of_type(), assert_value_of_type(), and list_columns() by using more general collection types.
  • Robust Type Checking: Improve the is_value_of_type() function to correctly handle non-type iterables by using a more direct not isinstance(check_type, type) check.
  • Constant Relocation: Move the log_levels Literal from collection_types.py to output.py to better align with its primary usage in logging utilities.
  • Flattening Logic: Refine the flatten() function to use Collection[Collection[Any]] for input parameters, removing the need for internal type ignores.

📖 Documentation & DX

  • Class Methods Documentation: Update the Defaults() class docstring to include a dedicated "Methods" section, documenting the .get(), ._validate_value_and_default(), and ._validate_type() methods.
  • Docstring Accuracy: Refactor parameter descriptions across multiple modules to reflect the shift from "tuple of types" to "Sequence of types" or "Collection of types".
  • Retry Metadata: Add descriptive docstrings for internal type aliases and generic type variables in the retry.py module.

🛠️ Bug Fixes & Refinements

  • Attribute Errors: Fix a missing .__name__ attribute access in error message generation for type assertions.
  • Typo Remediation: Correct several typos in docstrings and internal variable names across the checkers.py and bools.py modules.
  • Dictionary Reversal: Update dict_reverse_keys_and_values() to return explicit dict[str, Any] types, ensuring better compatibility with downstream consumers.

💪 What's Changed

  • Standardise Type Hints, Simplify Overloads, and Refactor Core Utilities by @chrimaho in #39

Full Changelog: v1.5.0...v1.6.0