pg.typing.Str¶
Accessible via pg.typing.Str.
- class Str(default=MISSING_VALUE, regex=None, is_noneable=False, frozen=False)[source]¶
Bases:
pg.typing.Generic,pg.typing.PrimitiveTypeValue spec for string type.
Examples:
# A required str value. pg.typing.Str() # A required str value which matches with a regular expression. pg.typing.Str(regex='foo.*')) # A str value with the default value set to 'foo'. pg.typing.Str(default='foo') # An optional str value with default value set to None. pg.typing.Str().noneable() # An optional str value with default value set to 'foo'. pg.typing.Str(default='foo').noneable() # A frozen str with value set to 'foo' that is not modifiable by subclasses. pg.typing.Str().freeze('foo')
Methods:
format([compact, verbose, root_indent])Format this object.
to_json(**kwargs)Returns a plain Python value as a representation for this object.
Attributes:
Returns regular expression for acceptable values.
- format(compact=False, verbose=True, root_indent=0, **kwargs)[source]¶
Format this object.
- Return type:
- to_json(**kwargs)[source]¶
Returns a plain Python value as a representation for this object.
A plain Python value are basic python types that can be serialized into JSON, e.g:
bool,int,float,str,dict(with string keys),list,tuplewhere the container types should have plain Python values as their values.