typet icon indicating copy to clipboard operation
typet copied to clipboard

Ideas for built-in types.

Open dangle opened this issue 7 years ago • 3 comments

typet needs to supply a rich collection of types by default. This issue will track ideas for the initial types.

dangle avatar Nov 17 '17 22:11 dangle

Create a SingletonObject by creating a private metaclass that inherits from Singleton and _ObjectMeta and a metaclass for a StrictSingletonObject that inherits from Singleton and _StrictObjectMeta.

The proposed use case would be a global settings object:

from typet import SingletonObject, File

class _Configuration(SingletonObject):
    config: File = '~/.my_config'

settings = _Configuration()

dangle avatar Nov 20 '17 08:11 dangle

  • JsonFile ** Validates a file's existence and that it can be parsed as JSON. ** Instances are dicts. ** Sliceable to indicate the type of dict returned. ** JsonFile implies JsonFile[dict] by default. ** JsonFile[OrderedDict]
    • JsonFile[DefaultDict[Any, Any]) ** If yaml is installed (optional in setup.py), parse YAML files?

dangle avatar Nov 20 '17 08:11 dangle

"Registerable" metaclass that registers subclassess automatically.

dangle avatar Nov 24 '17 12:11 dangle