Skip to content

Commit

Permalink
Reiterables x 9.
Browse files Browse the repository at this point in the history
This commit is the next in a commit chain deeply type-checking
**reiterables** (i.e., collections satisfying the
`collections.abc.Collection` protocol with guaranteed `O(1)` read-only
access to *only* the first collection item), en-route to *finally*
resolving feature request #167 kindly submitted by the perennial
brilliant @langfield (...*how I miss that awesome guy!*) several
lifetimes ago back when I was probably a wandering vagabond Buddhist
monk with a bad attitude, a begging bowl the size of my emaciated torso,
and an honestly pretty cool straw hat that glinted dangerously in the
firelight. Note that reiterables include *all* containers matched by one
or more of the following PEP 484- or 585-compliant type hints:

* `frozenset[...]`.
* `set[...]`.
* `collections.deque[...]`.
* `collections.abc.Collection[...]`.
* `collections.abc.KeysView[...]`.
* `collections.abc.MutableSet[...]`.
* `collections.abc.Set[...]`.
* `collections.abc.ValuesView[...]`.
* `typing.AbstractSet[...]`.
* `typing.Collection[...]`.
* `typing.Deque[...]`.
* `typing.FrozenSet[...]`.
* `typing.KeysView[...]`.
* `typing.MutableSet[...]`.
* `typing.Set[...]`.
* `typing.ValuesView[...]`.

Specifically, this commit continues reducing problematic DRY (Don't
Repeat Yourself) violations in @beartype's internal type-checking code
generator. (*Elliptical optics!*)
  • Loading branch information
leycec committed Jun 19, 2024
1 parent 4ee4191 commit 3ca08e4
Show file tree
Hide file tree
Showing 15 changed files with 659 additions and 489 deletions.
34 changes: 21 additions & 13 deletions beartype/_check/code/codemake.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@
CODE_HINT_CHILD_PLACEHOLDER_PREFIX,
CODE_HINT_CHILD_PLACEHOLDER_SUFFIX,
CODE_PEP484_INSTANCE_format,
CODE_PEP572_PITH_ASSIGN_EXPR_format,
)
from beartype._check.convert.convsanify import (
sanify_hint_child_if_unignorable_or_none,
sanify_hint_child,
)
from beartype._check.logic.logmap import (
HINT_SIGN_PEP484585_CONTAINER_ARGS_1_TO_LOGIC)
from beartype._conf.confcls import BeartypeConf
from beartype._data.code.datacodeindent import INDENT_LEVEL_TO_CODE
from beartype._data.code.datacodemagic import (
LINE_RSTRIP_INDEX_AND,
LINE_RSTRIP_INDEX_OR,
)
from beartype._data.code.pep.datacodepep484585 import (
CODE_PEP484585_GENERIC_CHILD_format,
CODE_PEP484585_GENERIC_PREFIX,
CODE_PEP484585_GENERIC_SUFFIX,
Expand All @@ -58,31 +73,24 @@
CODE_PEP484585_TUPLE_FIXED_NONEMPTY_PITH_CHILD_EXPR_format,
CODE_PEP484585_TUPLE_FIXED_PREFIX,
CODE_PEP484585_TUPLE_FIXED_SUFFIX,
)
from beartype._data.code.pep.datacodepep484604 import (
CODE_PEP484604_UNION_CHILD_PEP_format,
CODE_PEP484604_UNION_CHILD_NONPEP_format,
CODE_PEP484604_UNION_PREFIX,
CODE_PEP484604_UNION_SUFFIX,
CODE_PEP572_PITH_ASSIGN_EXPR_format,
)
from beartype._data.code.pep.datacodepep586 import (
CODE_PEP586_LITERAL_format,
CODE_PEP586_PREFIX_format,
CODE_PEP586_SUFFIX,
)
from beartype._data.code.pep.datacodepep593 import (
CODE_PEP593_VALIDATOR_IS_format,
CODE_PEP593_VALIDATOR_METAHINT_format,
CODE_PEP593_VALIDATOR_PREFIX,
CODE_PEP593_VALIDATOR_SUFFIX_format,
)
from beartype._check.convert.convsanify import (
sanify_hint_child_if_unignorable_or_none,
sanify_hint_child,
)
from beartype._check.logic.logicmap import (
HINT_SIGN_PEP484585_CONTAINER_ARGS_1_TO_LOGIC)
from beartype._conf.confcls import BeartypeConf
from beartype._data.code.datacodeindent import INDENT_LEVEL_TO_CODE
from beartype._data.code.datacodemagic import (
LINE_RSTRIP_INDEX_AND,
LINE_RSTRIP_INDEX_OR,
)
from beartype._data.error.dataerrmagic import (
EXCEPTION_PLACEHOLDER as EXCEPTION_PREFIX)
from beartype._data.hint.datahinttyping import (
Expand Down
Loading

0 comments on commit 3ca08e4

Please sign in to comment.