pane.field
pane.field
RenameStyle = t.Literal['snake', 'camel', 'pascal', 'kebab', 'scream']
module-attribute
List of supported field-renaming styles
Field
dataclass
Represents a materialized dataclass field.
Typically instantiated from a FieldSpec
.
Source code in pane/field.py
name
instance-attribute
Name of field
type
instance-attribute
Type of field. Must be Convertible
.
in_names
instance-attribute
List of names which convert to this field.
out_name
instance-attribute
Name this field converts into.
init = True
class-attribute
instance-attribute
Whether to add this field to init methods (and conversion from other types)
exclude = False
class-attribute
instance-attribute
Whether to exclude this field when converting to other types
repr = True
class-attribute
instance-attribute
Whether to include this field in repr
hash = True
class-attribute
instance-attribute
Whether to include this field in the generated hash method
compare = True
class-attribute
instance-attribute
Whether to include this field in generated comparison methods (eq, gt, etc.)
default = _MISSING
class-attribute
instance-attribute
Default value for field
default_factory = None
class-attribute
instance-attribute
Default value factory for field
kw_only = False
class-attribute
instance-attribute
Whether field is keyword only
converter = None
class-attribute
instance-attribute
Custom converter to use for this field.
make(name, ty, in_rename=None, out_rename=None)
classmethod
Source code in pane/field.py
FieldSpec
dataclass
Represents a field specification.
This hasn't been applied to a class yet, so some information is missing.
In most cases, end users should use the field()
function instead.
Source code in pane/field.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
|
rename = None
class-attribute
instance-attribute
Rename this field. Affects both in_names
and out_name
.
in_names = None
class-attribute
instance-attribute
Complete list of names which convert to this field.
aliases = None
class-attribute
instance-attribute
Additional list of names which convert to this field (excluding the name in Python).
out_name = None
class-attribute
instance-attribute
Name this field converts into.
init = True
class-attribute
instance-attribute
Whether to add this field to init methods (and conversion from other types)
exclude = False
class-attribute
instance-attribute
Whether to exclude this field when converting to other types
repr = True
class-attribute
instance-attribute
Whether to include this field in repr
hash = True
class-attribute
instance-attribute
Whether to include this field in the generated hash method.
compare = True
class-attribute
instance-attribute
Whether to include this field in generated comparison methods (eq, gt, etc.)
default = _MISSING
class-attribute
instance-attribute
Default value for field
default_factory = None
class-attribute
instance-attribute
Default value factory for field
kw_only = False
class-attribute
instance-attribute
Whether field is keyword only
ty = _MISSING
class-attribute
instance-attribute
Type of field, if known. Must be Convertible.
converter = None
class-attribute
instance-attribute
Custom converter to use for this field.
replace_typevars(replacements)
Apply type variable replacements to self
.
Source code in pane/field.py
make_field(name, in_rename=None, out_rename=None)
Make a Field
from this FieldSpec
.
Source code in pane/field.py
rename_field(field, style=None)
Rename field
to match style style
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field
|
str
|
Field name to rename |
required |
style
|
Optional[RenameStyle]
|
Style to match |
None
|
Source code in pane/field.py
field(*, rename=None, in_names=None, aliases=None, out_name=None, init=True, exclude=False, repr=True, hash=None, compare=True, default=_MISSING, default_factory=None, kw_only=False, converter=None)
field(*, rename: t.Optional[str] = None, in_names: None = None, aliases: None = None, out_name: t.Optional[str] = None, init: bool = True, exclude: bool = False, repr: bool = True, hash: t.Optional[bool] = None, compare: bool = True, default: t.Union[T, _Missing] = _MISSING, default_factory: t.Optional[t.Callable[[], T]] = None, kw_only: bool = False, converter: t.Optional[Converter[T]] = None) -> t.Any
field(*, rename: None = None, in_names: t.Sequence[str], aliases: None = None, out_name: t.Optional[str] = None, init: bool = True, exclude: bool = False, repr: bool = True, hash: t.Optional[bool] = None, compare: bool = True, default: t.Union[T, _Missing] = _MISSING, default_factory: t.Optional[t.Callable[[], T]] = None, kw_only: bool = False, converter: t.Optional[Converter[T]] = None) -> t.Any
field(*, rename: None = None, in_names: None = None, aliases: t.Sequence[str], out_name: t.Optional[str] = None, init: bool = True, exclude: bool = False, repr: bool = True, hash: t.Optional[bool] = None, compare: bool = True, default: t.Union[T, _Missing] = _MISSING, default_factory: t.Optional[t.Callable[[], T]] = None, kw_only: bool = False, converter: t.Optional[Converter[T]] = None) -> t.Any
field(*, rename: t.Optional[str] = None, in_names: t.Optional[t.Sequence[str]] = None, aliases: t.Optional[t.Sequence[str]] = None, out_name: t.Optional[str] = None, init: bool = True, exclude: bool = False, repr: bool = True, hash: t.Optional[bool] = None, compare: bool = True, default: t.Union[T, _Missing] = _MISSING, default_factory: t.Optional[t.Callable[[], T]] = None, kw_only: bool = False, converter: t.Optional[Converter[T]] = None) -> t.Any
Annotate a dataclass field.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rename
|
Optional[str]
|
Name to rename this field as. Used for both input and output. Useful when a field name should be different inside vs. outside of Python. |
None
|
in_names
|
Optional[Sequence[str]]
|
List of names which should convert into this field. If specified, the field name inside Python will be excluded (unlike |
None
|
aliases
|
Optional[Sequence[str]]
|
List of aliases (additional names) for this field. Includes the field name inside Python (unlike |
None
|
out_name
|
Optional[str]
|
Name which this field should convert into. |
None
|
init
|
bool
|
If |
True
|
exclude
|
bool
|
If |
False
|
repr
|
bool
|
Whether to include this field in the generated repr method. |
True
|
hash
|
Optional[bool]
|
Whether to include this field in the generated hash method. Defaults to |
None
|
compare
|
bool
|
Whether to include this field in generated comparison methods ( |
True
|
default
|
Union[T, _Missing]
|
Default value for field |
_MISSING
|
default_factory
|
Optional[Callable[[], T]]
|
Default value factory for field |
None
|
kw_only
|
bool
|
Whether the field is keyword-only. |
False
|