Skip to main content

A package for extended built-in types

Project description

typing-ex

A python package for extended typing (python 3.8+)

Coverage Lines of Code Quality Gate Status Reliability Rating Duplicated Lines (%) Vulnerabilities Bugs Security Rating Maintainability Rating

Installation

pip install typing-ex

Notice

Even with all tests passed, unexpected bugs might occur on edge cases

Frozen frozen.py

  • FrozenList: Immutable list
  • FrozenDict: Immutable dict
  • frozen_copy: Create frozen copy of supported types (Sequence, Set, Mapping)

TypeInfo type_info.py Documentation

  • TypeInfo: provide type information and run-time type checking
    • TypeInfo.get(t): alias of TypeInfo[t]
    • TypeInfo.of(value): return a TypeInfo object that represents the type of value
    • TypeInfo.check_union(t1, t2): check if union type t1 fulfill union type t2
    • TypeInfo[t].type: type
    • TypeInfo[t].origin: unsubscripted type
    • TypeInfo[t].args: type arguments
    • TypeInfo[t].name: name of type (including arguments)
    • TypeInfo[t].check_value(value): check if value matches the type in type info
    • TypeInfo[t].is_*: check if type is _

TypedDefaultDict typed_defaultdict.py Documentation

  • TypedDefaultDict: combining features of TypedDict and defaultdict with type checking in __init__, __setitem__, __setattr__ and update

    • TypedDefaultDict.schema: the schema dictionary: MappingProxyType[str, NamedTuple[default: Any, type:TypeInfo]]
    • TypedDefaultDict.on_get_unknown_property: called on getting unknown property
    • TypedDefaultDict.on_set_unknown_property: called on setting unknown property
    • TypedDefaultDict.set: set a property to a value without property check and type check
    • @factorymethod(property_name: str): defines a factory method for property
  • Attributes without type annotation or starting with underscore "_" will be treated as class variables

  • Good for writing schema as a class for JSON/YAML/XML/etc. data which provides both static and runtime type checking. Or you can use it as a class, but without the need to write __init__

EnumEx enum_ex.py Documentation

  • EnumEx is a Enum like class that support enum aliasing (keeping same value but different name).
    • EnumEx.__iter__: a generator of all non-alias enum instances.

    • EnumEx.names: a tuple of all enum names.

    • EnumEx.values: a tuple of all enum values.

    • EnumEx.enums: a tuple of all enum instances.

    • EnumEx.value_type: returns __value_type__ if defined, int otherwise.

    • EnumEx.X.value: value of enum X

    • EnumEx.X.name: name of enum X (i.e. X)

    • EnumEx.X_ALIAS.orig_name: original name of enum X_ALIAS (i.e. X)

    • EnumEx.X_ALIAS.origin: origin enum of X_ALIAS (i.e. EnumEx.X)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

typing_ex-0.1.33.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

typing_ex-0.1.33-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file typing_ex-0.1.33.tar.gz.

File metadata

  • Download URL: typing_ex-0.1.33.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.12.3 CPython/3.10.12

File hashes

Hashes for typing_ex-0.1.33.tar.gz
Algorithm Hash digest
SHA256 49bb89dce451bd63413f0a6f7b835de227bec6f25c7b7732b170eba7f4fcc5a2
MD5 2cc4aeef33697a7e956d977e8320ad11
BLAKE2b-256 239260105c7379338237798401a9968ffecca58ba065fccadf282cd854ccd40a

See more details on using hashes here.

File details

Details for the file typing_ex-0.1.33-py3-none-any.whl.

File metadata

  • Download URL: typing_ex-0.1.33-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.12.3 CPython/3.10.12

File hashes

Hashes for typing_ex-0.1.33-py3-none-any.whl
Algorithm Hash digest
SHA256 413177f0d3237a8c88c6bdd99402926bc85c1180266e4e8e95bd896d0673e722
MD5 fa615c6f973586040ca9815b09ec682a
BLAKE2b-256 c7d65138666fb0ea754df4d54bd1af929902b16c77aefdbffeaa4198817d89fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page