worktoy 1.2.3rc0__tar.gz → 1.3.0.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/PKG-INFO +2 -2
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/README.md +1 -1
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/pyproject.toml +1 -1
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/__init__.py +1 -1
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/dispatch/__init__.py +6 -1
- worktoy-1.3.0.dev1/src/worktoy/dispatch/_abstract.py +478 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/dispatch/_overload.py +99 -7
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/mcls/__init__.py +21 -5
- worktoy-1.3.0.dev1/src/worktoy/mcls/_abc_meta.py +98 -0
- worktoy-1.3.0.dev1/src/worktoy/mcls/_abc_object.py +32 -0
- worktoy-1.3.0.dev1/src/worktoy/mcls/_abc_space.py +552 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/mcls/space_hooks/__init__.py +5 -1
- worktoy-1.3.0.dev1/src/worktoy/mcls/space_hooks/_abc_hook.py +138 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/mcls/space_hooks/_load_space_hook.py +53 -2
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/mcls/space_hooks/_name_hook.py +58 -10
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/meta/__init__.py +8 -2
- worktoy-1.3.0.dev1/src/worktoy/waitaminute/meta/_missing_implementation.py +63 -0
- worktoy-1.3.0.dev1/src/worktoy/waitaminute/meta/_wrong_implementation.py +75 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy.egg-info/PKG-INFO +2 -2
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy.egg-info/SOURCES.txt +7 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/LICENSE +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/setup.cfg +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/core/__init__.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/core/_instance_owner.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/core/_meta_type.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/core/_object.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/core/control_flow/__init__.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/core/control_flow/_control_flow.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/core/control_flow/_control_space.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/core/control_flow/_meta_flow.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/core/control_flow/_skip_set.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/core/sentinels/__init__.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/core/sentinels/_args.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/core/sentinels/_deleted.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/core/sentinels/_desc.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/core/sentinels/_meta_call.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/core/sentinels/_owner.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/core/sentinels/_sentinel.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/core/sentinels/_this.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/desc/__init__.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/desc/_alias.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/desc/_attri_box.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/desc/_base_descriptor.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/desc/_fast_box.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/desc/_field.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/desc/_fix_box.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/desc/_root_alias.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/desc/_symbolic_name.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/dispatch/_call_me_maybe.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/dispatch/_dispatcher.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/dispatch/_flex_call.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/dispatch/_permuter.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/dispatch/_permuter_method.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/dispatch/_type_sig.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/ezdata/__init__.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/ezdata/_ez_data.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/ezdata/_ez_field.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/ezdata/_ez_hook.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/ezdata/_ez_meta.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/ezdata/_ez_space.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/ezdata/_ez_store.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/ezdata/_fields.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/keenum/__init__.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/keenum/_access_num.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/keenum/_kee_box.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/keenum/_kee_flag.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/keenum/_kee_flags.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/keenum/_kee_flags_hook.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/keenum/_kee_flags_meta.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/keenum/_kee_flags_space.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/keenum/_kee_member.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/keenum/_kee_meta.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/keenum/_kee_meta_meta.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/keenum/_kee_num.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/keenum/_kee_space.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/keenum/_kee_space_hook.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/lorem_ipsum/__init__.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/lorem_ipsum/_base_generator.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/lorem_ipsum/_clause.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/lorem_ipsum/_gaussian_lengths.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/lorem_ipsum/_paragraph.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/lorem_ipsum/_sentence.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/lorem_ipsum/_stochastic_variable.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/lorem_ipsum/_stochastic_word.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/lorem_ipsum/_words.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/mcls/_abstract_metaclass.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/mcls/_abstract_namespace.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/mcls/_base_meta.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/mcls/_base_object.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/mcls/_base_space.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/mcls/space_hooks/_abstract_space_hook.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/mcls/space_hooks/_flex_call_hook.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/mcls/space_hooks/_reserved_names.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/mcls/space_hooks/_reserved_namespace_hook.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/mcls/space_hooks/_space_desc.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/py.typed +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/__init__.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/_args_count.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/_bipartite_matching.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/_class_body_template.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/_directory.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/_exception_info.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/_join_words.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/_maybe.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/_quick_desc.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/_replace_flex.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/_resolve_mro.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/_slice_len.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/_string_list.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/_text_fmt.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/_type_cast.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/_unpack.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/_valid_slice.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/_word_wrap.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/combinatorics/__init__.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/combinatorics/_arrangement.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/combinatorics/_arrangements.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/utilities/combinatorics/_index_permutations.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/__init__.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/_alternative_warning.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/_deprecated_promise.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/_missing_variable.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/_redundant_keyword.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/_risk_warning.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/_subclass_exception.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/_type_exception.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/_uncheckable_type.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/_unpack_exception.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/_variable_not_none.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/_work_toy_exception.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/_work_toy_warning.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/control_flow/__init__.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/desc/__init__.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/desc/_access_error.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/desc/_dangling_alias.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/desc/_descriptor_exception.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/desc/_missing_instance_dict.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/desc/_nameless_callback.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/desc/_not_a_descriptor.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/desc/_overload_reference.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/desc/_phantom_box_error.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/desc/_protected_error.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/desc/_read_only_error.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/desc/_recursive_read.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/desc/_reference_conflict.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/desc/_shared_descriptor.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/desc/_without_exception.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/desc/_write_once_error.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/dispatch/__init__.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/dispatch/_bare_overload.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/dispatch/_dispatch_exception.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/dispatch/_duplicate_signature.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/dispatch/_type_cast_exception.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/dispatch/_unbound_cast_hook.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/ezdata/__init__.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/ezdata/_class_field_error.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/ezdata/_duplicate_error.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/ezdata/_extra_keyword_exception.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/ezdata/_extra_positional_exception.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/ezdata/_incomplete_field_exception.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/ezdata/_kw_only_exception.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/ezdata/_repeated_field_exception.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/ezdata/_reserved_attribute_error.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/ezdata/_reserved_field_error.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/ezdata/_reserved_method_error.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/keenum/__init__.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/keenum/_kee_box_exception.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/keenum/_kee_box_type_error.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/keenum/_kee_box_value_error.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/keenum/_kee_case_exception.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/keenum/_kee_duplicate.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/keenum/_kee_flag_duplicate.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/keenum/_kee_flag_name_error.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/keenum/_kee_member_name_error.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/keenum/_kee_name_conflict.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/keenum/_kee_resolve_error.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/keenum/_kee_type_exception.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/keenum/_kee_write_once_error.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/meta/_claimed_name.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/meta/_control_class_error.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/meta/_del_exception.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/meta/_duplicate_hook.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/meta/_duplicate_sentinel.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/meta/_hook_exception.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/meta/_illegal_instantiation.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/meta/_mixed_method_kind.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/meta/_overload_conflict.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/meta/_questionable_syntax.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/meta/_rebound_overload.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/meta/_reserved_name.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/meta/_shadowed_class_hook.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/meta/_slots_refused.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/waitaminute/meta/_unbound_class_hook.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/work_test/__init__.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/work_test/_base_test.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/work_test/_complex_mixin.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/work_test/_complex_test.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/work_test/_sub_test.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/work_test/_test_meta.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/work_test/_test_space.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/work_test/samplers/__init__.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/work_test/samplers/_base_sampler.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/work_test/samplers/_float_sampler.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/work_test/samplers/_gaussian_sampler.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/work_test/samplers/_int_sampler.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/work_test/samplers/_lorem_sampler.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/work_test/samplers/_lorem_text.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/work_test/samplers/_sampler_meta.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/work_test/samplers/_symbolic_sampler.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy/work_test/samplers/_word_sampler.py +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy.egg-info/dependency_links.txt +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/src/worktoy.egg-info/top_level.txt +0 -0
- {worktoy-1.2.3rc0 → worktoy-1.3.0.dev1}/tests/test_smoke.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: worktoy
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0.dev1
|
|
4
4
|
Summary: Declarative structure for Python that enforces types at runtime and enables true function overloading
|
|
5
5
|
Author-email: Asger Jon Vistisen <asgerjon2@gmail.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -32,7 +32,7 @@ Dynamic: license-file
|
|
|
32
32
|
[](https://pypi.org/project/worktoy/)
|
|
33
33
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
34
34
|
|
|
35
|
-
# worktoy v1.
|
|
35
|
+
# worktoy v1.3.0-dev1 (development build)
|
|
36
36
|
|
|
37
37
|
**worktoy** provides utilities for Python development focused on
|
|
38
38
|
reducing boilerplate while improving type safety and readability. Each
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://pypi.org/project/worktoy/)
|
|
5
5
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
6
6
|
|
|
7
|
-
# worktoy v1.
|
|
7
|
+
# worktoy v1.3.0-dev1 (development build)
|
|
8
8
|
|
|
9
9
|
**worktoy** provides utilities for Python development focused on
|
|
10
10
|
reducing boilerplate while improving type safety and readability. Each
|
|
@@ -48,7 +48,7 @@ and the enclosing class is left without the decoration.
|
|
|
48
48
|
# Copyright (c) 2025-2026 Asger Jon Vistisen
|
|
49
49
|
from __future__ import annotations
|
|
50
50
|
|
|
51
|
-
__version__ = '1.
|
|
51
|
+
__version__ = '1.3.0-dev1'
|
|
52
52
|
|
|
53
53
|
from . import utilities
|
|
54
54
|
from . import waitaminute
|
|
@@ -6,13 +6,16 @@ live dispatch happens one layer up, where 'BaseMeta' in 'worktoy.mcls'
|
|
|
6
6
|
compiles them into a 'Dispatcher' during class construction. They serve
|
|
7
7
|
a class based on 'BaseObject' or built by a metaclass based on 'BaseMeta';
|
|
8
8
|
a class whose metaclass comes from another library takes a metaclass
|
|
9
|
-
combined with 'BaseMeta'.
|
|
9
|
+
combined with 'BaseMeta'. The 'abstract' decorator declares a method, or
|
|
10
|
+
the signatures of an overloaded name, that a subclass has to write; a
|
|
11
|
+
class built by 'ABCMeta' of 'worktoy.mcls' holds its subclasses to it.
|
|
10
12
|
|
|
11
13
|
- flexCall, isFlex
|
|
12
14
|
- CallMeMaybe
|
|
13
15
|
- Permuter, PermuterMethod
|
|
14
16
|
- TypeSig
|
|
15
17
|
- Dispatcher
|
|
18
|
+
- abstract
|
|
16
19
|
- overload
|
|
17
20
|
"""
|
|
18
21
|
# Apache-2.0 license
|
|
@@ -25,6 +28,7 @@ from ._permuter import Permuter
|
|
|
25
28
|
from ._permuter_method import PermuterMethod
|
|
26
29
|
from ._type_sig import TypeSig
|
|
27
30
|
from ._dispatcher import Dispatcher
|
|
31
|
+
from ._abstract import abstract
|
|
28
32
|
from ._overload import overload
|
|
29
33
|
|
|
30
34
|
__all__ = [
|
|
@@ -35,5 +39,6 @@ __all__ = [
|
|
|
35
39
|
'PermuterMethod',
|
|
36
40
|
'TypeSig',
|
|
37
41
|
'Dispatcher',
|
|
42
|
+
'abstract',
|
|
38
43
|
'overload',
|
|
39
44
|
]
|
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
"""
|
|
2
|
+
The 'abstract' decorator declares a method a subclass has to write, and
|
|
3
|
+
is the record of that declaration.
|
|
4
|
+
"""
|
|
5
|
+
# Apache-2.0 license
|
|
6
|
+
# Copyright (c) 2026 Asger Jon Vistisen
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import dis
|
|
10
|
+
from types import FunctionType
|
|
11
|
+
from typing import TYPE_CHECKING
|
|
12
|
+
|
|
13
|
+
from ..utilities import textFmt
|
|
14
|
+
from ..waitaminute import TypeException
|
|
15
|
+
|
|
16
|
+
if TYPE_CHECKING: # pragma: no cover, no mutate
|
|
17
|
+
from typing import Any, Optional
|
|
18
|
+
|
|
19
|
+
_CO_VARARGS: int = 0x04 # CPython compile flag
|
|
20
|
+
_CO_VARKEYWORDS: int = 0x08 # CPython compile flag
|
|
21
|
+
# CO_GENERATOR, CO_COROUTINE, CO_ITERABLE_COROUTINE, CO_ASYNC_GENERATOR
|
|
22
|
+
_CO_GENERATORS: int = 0x20 | 0x80 | 0x100 | 0x200
|
|
23
|
+
|
|
24
|
+
# What Python compiles a blank body to, whichever way it is written:
|
|
25
|
+
# a load of 'None' and a return, under the names of every version from
|
|
26
|
+
# 3.7 to 3.15. 'RESUME' opens every function from 3.11 on.
|
|
27
|
+
_SKIPPED_STEPS: tuple = ('RESUME', 'NOP')
|
|
28
|
+
_BLANK_STEPS: tuple = (
|
|
29
|
+
'LOAD_CONST', 'LOAD_COMMON_CONSTANT', 'RETURN_VALUE', 'RETURN_CONST',
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class abstract: # NOQA
|
|
35
|
+
"""
|
|
36
|
+
Some classes declare a method without having anything to run for it:
|
|
37
|
+
every class based on them has to write it, as a model of a list has to
|
|
38
|
+
say how many rows it holds. The class body must be able to say so at
|
|
39
|
+
the method, for a bound method, a classmethod and a staticmethod, and
|
|
40
|
+
for the signatures of an overloaded name:
|
|
41
|
+
|
|
42
|
+
class Model(BaseObject, metaclass=ABCMeta):
|
|
43
|
+
|
|
44
|
+
@abstract
|
|
45
|
+
def rowCount(self) -> int: ...
|
|
46
|
+
|
|
47
|
+
@overload(str, int)
|
|
48
|
+
@abstract
|
|
49
|
+
def data(self, index: str, role: int) -> Any: ...
|
|
50
|
+
|
|
51
|
+
Such a declaration runs nothing, so a function with a body under it
|
|
52
|
+
is a mistake and must be refused where it is written. What it declares
|
|
53
|
+
must be on record, since a subclass writing the method is held to it:
|
|
54
|
+
the kind of method, and what the method receives. And a call that
|
|
55
|
+
does reach the declaration, as through 'super()', must do nothing.
|
|
56
|
+
|
|
57
|
+
Implementation
|
|
58
|
+
--------------
|
|
59
|
+
|
|
60
|
+
'@abstract' over a blank function gives an 'abstract' object, the
|
|
61
|
+
record of that function, as '@overload' gives a record of its own. A
|
|
62
|
+
body of '...', of 'pass', of a docstring alone or of 'return None' is
|
|
63
|
+
blank, Python compiling each to the same thing; any other body, and a
|
|
64
|
+
generator or coroutine function, raises 'TypeError'. The record keeps
|
|
65
|
+
the function, its name and its docstring, gives the shape of its
|
|
66
|
+
parameters through 'getShape', and does nothing when called. Given a
|
|
67
|
+
'classmethod' or 'staticmethod' object it returns one of the same kind
|
|
68
|
+
over the record. Given the record of '@overload', it puts itself in
|
|
69
|
+
the place of the function that record holds, so '@abstract' stands at
|
|
70
|
+
any position among the '@overload' decorators of a stack. A class
|
|
71
|
+
built by 'ABCMeta' of 'worktoy.mcls' holds its subclasses to what is
|
|
72
|
+
declared, and the space hook of its namespace says so on each record
|
|
73
|
+
of its body by setting '__abc_only__'. A record no such hook took is
|
|
74
|
+
refused as its class is created, since nothing there would hold a
|
|
75
|
+
subclass to it.
|
|
76
|
+
|
|
77
|
+
Attributes
|
|
78
|
+
----------
|
|
79
|
+
|
|
80
|
+
__wrapped__ : FunctionType
|
|
81
|
+
The blank function.
|
|
82
|
+
|
|
83
|
+
__name__, __qualname__, __module__, __doc__ : str
|
|
84
|
+
Those of the blank function.
|
|
85
|
+
|
|
86
|
+
__abc_only__ : bool
|
|
87
|
+
'False' on a new record, and set to 'True' by the namespace of an
|
|
88
|
+
abstract class for each record of its body.
|
|
89
|
+
|
|
90
|
+
__declaring_class__ : type or None
|
|
91
|
+
The class whose body declares the record, once that class exists,
|
|
92
|
+
and 'None' until then. A class based on it inherits the record and
|
|
93
|
+
leaves this as it is.
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
97
|
+
# NAMESPACE # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
98
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
99
|
+
|
|
100
|
+
# Private Variables
|
|
101
|
+
__abc_only__: bool = False
|
|
102
|
+
__declaring_class__: Optional[type] = None
|
|
103
|
+
|
|
104
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
105
|
+
# STATIC METHODS # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
106
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
107
|
+
|
|
108
|
+
@staticmethod
|
|
109
|
+
def _isBlank(func: FunctionType) -> bool:
|
|
110
|
+
"""
|
|
111
|
+
A function under '@abstract' must have no implementation, and that
|
|
112
|
+
must be read off the function itself, on every version of Python.
|
|
113
|
+
|
|
114
|
+
Implementation
|
|
115
|
+
--------------
|
|
116
|
+
|
|
117
|
+
Python compiles a body of '...', of 'pass', of a docstring alone and
|
|
118
|
+
of 'return None' to a load of 'None' and a return, and nothing else.
|
|
119
|
+
The steps 'dis' gives are held to that: each is one of those two,
|
|
120
|
+
under any of the names the versions give them, and carries no value
|
|
121
|
+
but 'None'.
|
|
122
|
+
|
|
123
|
+
Parameters
|
|
124
|
+
----------
|
|
125
|
+
|
|
126
|
+
func : FunctionType
|
|
127
|
+
The function.
|
|
128
|
+
|
|
129
|
+
Returns
|
|
130
|
+
-------
|
|
131
|
+
|
|
132
|
+
bool
|
|
133
|
+
Whether the body of the function is blank.
|
|
134
|
+
"""
|
|
135
|
+
for step in dis.get_instructions(func):
|
|
136
|
+
if step.opname in _SKIPPED_STEPS:
|
|
137
|
+
continue
|
|
138
|
+
if step.opname not in _BLANK_STEPS:
|
|
139
|
+
return False
|
|
140
|
+
if step.argval is not None:
|
|
141
|
+
return False
|
|
142
|
+
return True
|
|
143
|
+
|
|
144
|
+
@staticmethod
|
|
145
|
+
def shapeOf(func: FunctionType, kind: Any) -> tuple:
|
|
146
|
+
"""
|
|
147
|
+
Whether a method written in a subclass can take what an abstract one
|
|
148
|
+
declares is decided by what each receives: how many arguments by
|
|
149
|
+
position, whether any number more, which by keyword alone, and
|
|
150
|
+
whether any keyword. A default plays no part: a parameter counts the
|
|
151
|
+
same with one or without.
|
|
152
|
+
|
|
153
|
+
Implementation
|
|
154
|
+
--------------
|
|
155
|
+
|
|
156
|
+
The counts are read off the code of the function. The first
|
|
157
|
+
positional parameter of a bound method or a classmethod is the
|
|
158
|
+
receiver and is left out; a function taking the receiver through
|
|
159
|
+
'*args' counts none, and one that cannot take a receiver at all
|
|
160
|
+
counts -1, which fits nothing.
|
|
161
|
+
|
|
162
|
+
Parameters
|
|
163
|
+
----------
|
|
164
|
+
|
|
165
|
+
func : FunctionType
|
|
166
|
+
The function.
|
|
167
|
+
|
|
168
|
+
kind : Any
|
|
169
|
+
'classmethod', 'staticmethod', or 'None' for a bound method.
|
|
170
|
+
|
|
171
|
+
Returns
|
|
172
|
+
-------
|
|
173
|
+
|
|
174
|
+
tuple
|
|
175
|
+
The number of positional parameters after the receiver, whether
|
|
176
|
+
the function takes '*args', the names of its keyword-only
|
|
177
|
+
parameters, and whether it takes '**kwargs'.
|
|
178
|
+
"""
|
|
179
|
+
code = func.__code__
|
|
180
|
+
count = code.co_argcount
|
|
181
|
+
starred = True if code.co_flags & _CO_VARARGS else False
|
|
182
|
+
doubled = True if code.co_flags & _CO_VARKEYWORDS else False
|
|
183
|
+
if kind is not staticmethod:
|
|
184
|
+
if count or not starred:
|
|
185
|
+
count -= 1
|
|
186
|
+
first = code.co_argcount
|
|
187
|
+
keyed = code.co_varnames[first:first + code.co_kwonlyargcount]
|
|
188
|
+
return count, starred, (*keyed,), doubled
|
|
189
|
+
|
|
190
|
+
@staticmethod
|
|
191
|
+
def fits(declared: tuple, written: tuple) -> bool:
|
|
192
|
+
"""
|
|
193
|
+
A method written in a subclass implements an abstract one when it can
|
|
194
|
+
receive everything the abstract one declares.
|
|
195
|
+
|
|
196
|
+
Implementation
|
|
197
|
+
--------------
|
|
198
|
+
|
|
199
|
+
A written function takes exactly as many arguments by position as it
|
|
200
|
+
has positional parameters, and with '*args' any number from there
|
|
201
|
+
up. Where the declaration itself takes any number, the written one
|
|
202
|
+
has to as well, from no more than the declared number. Each
|
|
203
|
+
keyword-only parameter declared needs the same one or '**kwargs',
|
|
204
|
+
and a declared '**kwargs' needs '**kwargs'.
|
|
205
|
+
|
|
206
|
+
Parameters
|
|
207
|
+
----------
|
|
208
|
+
|
|
209
|
+
declared : tuple
|
|
210
|
+
The shape declared, as 'shapeOf' gives one.
|
|
211
|
+
|
|
212
|
+
written : tuple
|
|
213
|
+
The shape of the function written.
|
|
214
|
+
|
|
215
|
+
Returns
|
|
216
|
+
-------
|
|
217
|
+
|
|
218
|
+
bool
|
|
219
|
+
Whether the written shape can take what the declared one takes.
|
|
220
|
+
"""
|
|
221
|
+
count, starred, keyed, doubled = declared
|
|
222
|
+
writtenCount, writtenStarred, writtenKeyed, writtenDoubled = written
|
|
223
|
+
if starred and not writtenStarred:
|
|
224
|
+
return False
|
|
225
|
+
if writtenStarred:
|
|
226
|
+
if writtenCount > count:
|
|
227
|
+
return False
|
|
228
|
+
elif writtenCount != count:
|
|
229
|
+
return False
|
|
230
|
+
if doubled and not writtenDoubled:
|
|
231
|
+
return False
|
|
232
|
+
for name in keyed:
|
|
233
|
+
if name not in writtenKeyed and not writtenDoubled:
|
|
234
|
+
return False
|
|
235
|
+
return True
|
|
236
|
+
|
|
237
|
+
@staticmethod
|
|
238
|
+
def describe(kind: Any, shape: tuple) -> str:
|
|
239
|
+
"""
|
|
240
|
+
The refusal of a wrong implementation must say what was declared and
|
|
241
|
+
what was written in the same words, so the two can be compared.
|
|
242
|
+
|
|
243
|
+
Parameters
|
|
244
|
+
----------
|
|
245
|
+
|
|
246
|
+
kind : Any
|
|
247
|
+
'classmethod', 'staticmethod', or 'None' for a bound method.
|
|
248
|
+
|
|
249
|
+
shape : tuple
|
|
250
|
+
A shape as 'shapeOf' gives one.
|
|
251
|
+
|
|
252
|
+
Returns
|
|
253
|
+
-------
|
|
254
|
+
|
|
255
|
+
str
|
|
256
|
+
The kind and what it takes, as "a method taking 2 by position".
|
|
257
|
+
"""
|
|
258
|
+
count, starred, keyed, doubled = shape
|
|
259
|
+
if kind is classmethod:
|
|
260
|
+
out = 'a classmethod taking %d' % count
|
|
261
|
+
elif kind is staticmethod:
|
|
262
|
+
out = 'a staticmethod taking %d' % count
|
|
263
|
+
else:
|
|
264
|
+
out = 'a method taking %d' % count
|
|
265
|
+
if starred:
|
|
266
|
+
out = '%s or more' % out
|
|
267
|
+
out = '%s by position' % out
|
|
268
|
+
for name in keyed:
|
|
269
|
+
out = "%s, '%s' by keyword" % (out, name)
|
|
270
|
+
if doubled:
|
|
271
|
+
out = '%s, any keyword' % out
|
|
272
|
+
return out
|
|
273
|
+
|
|
274
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
275
|
+
# GETTERS # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
276
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
277
|
+
|
|
278
|
+
def requireHost(self, mcls: type, className: str, name: str) -> None:
|
|
279
|
+
"""
|
|
280
|
+
An abstract method is a claim on the classes based on its class, and
|
|
281
|
+
only a namespace made for it holds them to the claim. Declared in
|
|
282
|
+
any other class, the method would be answered with nothing and no
|
|
283
|
+
subclass would ever be asked to write it, so the declaration must
|
|
284
|
+
fail as that class is created.
|
|
285
|
+
|
|
286
|
+
Implementation
|
|
287
|
+
--------------
|
|
288
|
+
|
|
289
|
+
The space hook of an abstract class sets '__abc_only__' on each
|
|
290
|
+
record of its body, as 'ABCHook' of 'worktoy.mcls' does. A record
|
|
291
|
+
whose flag is still 'False' was taken by no such hook.
|
|
292
|
+
|
|
293
|
+
Parameters
|
|
294
|
+
----------
|
|
295
|
+
|
|
296
|
+
mcls : type
|
|
297
|
+
The metaclass of the class whose body declares the method, for
|
|
298
|
+
the message.
|
|
299
|
+
|
|
300
|
+
className : str
|
|
301
|
+
The name of that class.
|
|
302
|
+
|
|
303
|
+
name : str
|
|
304
|
+
The name declared abstract.
|
|
305
|
+
|
|
306
|
+
Raises
|
|
307
|
+
------
|
|
308
|
+
|
|
309
|
+
TypeError
|
|
310
|
+
No space hook of an abstract class took the record.
|
|
311
|
+
"""
|
|
312
|
+
if self.__abc_only__:
|
|
313
|
+
return
|
|
314
|
+
infoSpec = """The class body of '%s' declares '%s' abstract, and its
|
|
315
|
+
metaclass '%s' is not based on 'ABCMeta', so no class based on it
|
|
316
|
+
would be held to writing '%s'. A class declaring abstract methods is
|
|
317
|
+
built by 'ABCMeta' of 'worktoy.mcls'."""
|
|
318
|
+
info = infoSpec % (className, name, mcls.__name__, name)
|
|
319
|
+
raise TypeError(textFmt(info))
|
|
320
|
+
|
|
321
|
+
def getShape(self, kind: Any) -> tuple:
|
|
322
|
+
"""
|
|
323
|
+
What the blank function declares depends on the kind of method it
|
|
324
|
+
is, which the layers around the record say, not the record.
|
|
325
|
+
|
|
326
|
+
Parameters
|
|
327
|
+
----------
|
|
328
|
+
|
|
329
|
+
kind : Any
|
|
330
|
+
'classmethod', 'staticmethod', or 'None' for a bound method.
|
|
331
|
+
|
|
332
|
+
Returns
|
|
333
|
+
-------
|
|
334
|
+
|
|
335
|
+
tuple
|
|
336
|
+
The shape of the blank function, as 'shapeOf' gives it.
|
|
337
|
+
"""
|
|
338
|
+
return self.shapeOf(self.__wrapped__, kind)
|
|
339
|
+
|
|
340
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
341
|
+
# CONSTRUCTORS # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
342
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
343
|
+
|
|
344
|
+
def __new__(cls, func: Any) -> Any:
|
|
345
|
+
"""
|
|
346
|
+
'@abstract' is written above a blank function, above or below
|
|
347
|
+
'@classmethod' or '@staticmethod', and at any position among the
|
|
348
|
+
'@overload' decorators of a stack. Whatever it receives, the one
|
|
349
|
+
function of the stack must end up declared abstract, and anything
|
|
350
|
+
that cannot be an abstract declaration must be refused at that line.
|
|
351
|
+
|
|
352
|
+
Implementation
|
|
353
|
+
--------------
|
|
354
|
+
|
|
355
|
+
The 'classmethod' and 'staticmethod' layers are taken off first. A
|
|
356
|
+
record of '@overload' underneath is asked to put a new 'abstract' in
|
|
357
|
+
the place of its function, and is returned as it came. A function is
|
|
358
|
+
checked and recorded, and returned under a layer of the kind it came
|
|
359
|
+
in.
|
|
360
|
+
|
|
361
|
+
Parameters
|
|
362
|
+
----------
|
|
363
|
+
|
|
364
|
+
func : Any
|
|
365
|
+
A blank function, a classmethod or staticmethod over one, or the
|
|
366
|
+
record of an '@overload' decorator below.
|
|
367
|
+
|
|
368
|
+
Returns
|
|
369
|
+
-------
|
|
370
|
+
|
|
371
|
+
Any
|
|
372
|
+
The record, under a layer of the kind it came in, or the record of
|
|
373
|
+
'@overload' it was given.
|
|
374
|
+
|
|
375
|
+
Raises
|
|
376
|
+
------
|
|
377
|
+
|
|
378
|
+
TypeException
|
|
379
|
+
What lies under the layers is no plain function, as a function
|
|
380
|
+
declared abstract already.
|
|
381
|
+
|
|
382
|
+
TypeError
|
|
383
|
+
The function has a body, or is a generator or coroutine function.
|
|
384
|
+
|
|
385
|
+
MixedMethodKind
|
|
386
|
+
The function is decorated as both a classmethod and a
|
|
387
|
+
staticmethod.
|
|
388
|
+
"""
|
|
389
|
+
# Local import: 'overload' loads after this file, which it imports.
|
|
390
|
+
from . import overload
|
|
391
|
+
kinds, inner = overload.peelMethodKinds(func)
|
|
392
|
+
if isinstance(inner, overload):
|
|
393
|
+
inner._makeAbstract(cls)
|
|
394
|
+
return func
|
|
395
|
+
if not isinstance(inner, FunctionType):
|
|
396
|
+
raise TypeException('func', inner, FunctionType)
|
|
397
|
+
name: str = inner.__name__
|
|
398
|
+
kind = overload.agreeMethodKind(kinds, name)
|
|
399
|
+
if inner.__code__.co_flags & _CO_GENERATORS:
|
|
400
|
+
infoSpec = """The function '%s' under '@abstract' is a generator or
|
|
401
|
+
a coroutine function. An abstract method is declared on an ordinary
|
|
402
|
+
function."""
|
|
403
|
+
raise TypeError(textFmt(infoSpec % name))
|
|
404
|
+
if not cls._isBlank(inner):
|
|
405
|
+
infoSpec = """The function '%s' under '@abstract' has a body. An
|
|
406
|
+
abstract method declares what a subclass has to write and runs
|
|
407
|
+
nothing itself, so its body is left blank: '...', 'pass' or a
|
|
408
|
+
docstring alone."""
|
|
409
|
+
raise TypeError(textFmt(infoSpec % name))
|
|
410
|
+
self = object.__new__(cls)
|
|
411
|
+
self.__wrapped__ = inner
|
|
412
|
+
self.__name__ = name
|
|
413
|
+
self.__qualname__ = inner.__qualname__
|
|
414
|
+
self.__module__ = inner.__module__
|
|
415
|
+
self.__doc__ = inner.__doc__
|
|
416
|
+
if kind is None:
|
|
417
|
+
return self
|
|
418
|
+
return kind(self)
|
|
419
|
+
|
|
420
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
421
|
+
# Python API # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
422
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
423
|
+
|
|
424
|
+
def __call__(self, *args, **kwargs) -> None:
|
|
425
|
+
"""
|
|
426
|
+
A call may reach an abstract method, as through 'super()' from the
|
|
427
|
+
method a subclass wrote, or on a class that is still abstract through
|
|
428
|
+
a classmethod or a staticmethod. The declaration has nothing to run.
|
|
429
|
+
|
|
430
|
+
Implementation
|
|
431
|
+
--------------
|
|
432
|
+
|
|
433
|
+
Whatever it is called with, it does nothing and returns 'None', as an
|
|
434
|
+
abstract method of Python's 'abc' with a blank body does.
|
|
435
|
+
"""
|
|
436
|
+
|
|
437
|
+
def __set_name__(self, owner: type, name: str) -> None:
|
|
438
|
+
"""
|
|
439
|
+
A record left in the body of a class that no hosting metaclass built
|
|
440
|
+
must fail as that class is created, not at the first call.
|
|
441
|
+
|
|
442
|
+
Implementation
|
|
443
|
+
--------------
|
|
444
|
+
|
|
445
|
+
Python calls this method for a record held in the dictionary of a
|
|
446
|
+
new class. 'requireHost' refuses a record whose '__abc_only__' no
|
|
447
|
+
space hook of an abstract class has set, and a record that passes
|
|
448
|
+
keeps the class as '__declaring_class__'. Before Python 3.12 the
|
|
449
|
+
refusal reaches the class statement wrapped in a 'RuntimeError'.
|
|
450
|
+
Python does not call this method for a record under a 'classmethod'
|
|
451
|
+
or 'staticmethod' layer, nor for one a dispatcher holds; in a class
|
|
452
|
+
built by 'BaseMeta' those are refused by 'LoadSpaceHook' instead.
|
|
453
|
+
In a plain Python class nothing asks a record under such a layer,
|
|
454
|
+
and it passes unnoticed: 'classmethod' and 'staticmethod' wrap
|
|
455
|
+
anything and pass no '__set_name__' on.
|
|
456
|
+
|
|
457
|
+
Parameters
|
|
458
|
+
----------
|
|
459
|
+
|
|
460
|
+
owner : type
|
|
461
|
+
The class being created.
|
|
462
|
+
|
|
463
|
+
name : str
|
|
464
|
+
The name the record is bound to.
|
|
465
|
+
|
|
466
|
+
Raises
|
|
467
|
+
------
|
|
468
|
+
|
|
469
|
+
TypeError
|
|
470
|
+
No space hook of an abstract class took the record.
|
|
471
|
+
"""
|
|
472
|
+
self.requireHost(type(owner), owner.__name__, name)
|
|
473
|
+
self.__declaring_class__ = owner
|
|
474
|
+
|
|
475
|
+
def __str__(self, ) -> str:
|
|
476
|
+
return """abstract '%s'""" % self.__name__
|
|
477
|
+
|
|
478
|
+
__repr__ = __str__
|