Fix typos discovered by codespell (#3096)

This commit is contained in:
Christian Clauss
2021-09-04 00:05:36 +02:00
committed by GitHub
parent 796a7531cd
commit 90080ba0de
8 changed files with 9 additions and 11 deletions
+1 -1
View File
@@ -495,7 +495,7 @@ _(This script is complete, it should run "as is")_
in the same model can result in surprising field orderings. (This is due to limitations of python)
Therefore, **we recommend adding type annotations to all fields**, even when a default value
would determine the type by itself to guarentee field order is preserved.
would determine the type by itself to guarantee field order is preserved.
## Required fields
+1 -1
View File
@@ -232,7 +232,7 @@ By flipping `env_settings` and `init_settings`, environment variables now have p
### Adding sources
As explained earlier, *pydantic* ships with multiples built-in settings sources. However, you may occationally
As explained earlier, *pydantic* ships with multiples built-in settings sources. However, you may occasionally
need to add your own custom sources, `customise_sources` makes this very easy:
```py
+1 -1
View File
@@ -222,7 +222,7 @@ def parse_duration(value: StrBytesIntFloat) -> timedelta:
return value
if isinstance(value, (int, float)):
# bellow code requires a string
# below code requires a string
value = str(value)
elif isinstance(value, bytes):
value = value.decode()
+1 -1
View File
@@ -246,7 +246,7 @@ def Field(
schema will have a ``maxLength`` validation keyword
:param allow_mutation: a boolean which defaults to True. When False, the field raises a TypeError if the field is
assigned on an instance. The BaseModel Config must set validate_assignment to True
:param regex: only applies to strings, requires the field match agains a regular expression
:param regex: only applies to strings, requires the field match against a regular expression
pattern string. The schema will have a ``pattern`` validation keyword
:param repr: show this field in the representation
:param **extra: any additional keyword arguments will be added as is to the schema
+1 -1
View File
@@ -143,7 +143,7 @@ class GenericModel(BaseModel):
def replace_types(type_: Any, type_map: Mapping[Any, Any]) -> Any:
"""Return type with all occurances of `type_map` keys recursively replaced with their values.
"""Return type with all occurrences of `type_map` keys recursively replaced with their values.
:param type_: Any type, class or generic alias
:param type_map: Mapping from `TypeVar` instance to concrete types.
+2 -4
View File
@@ -386,7 +386,7 @@ def get_flat_models_from_field(field: ModelField, known_models: TypeModelSet) ->
def get_flat_models_from_fields(fields: Sequence[ModelField], known_models: TypeModelSet) -> TypeModelSet:
"""
Take a list of Pydantic ``ModelField``s (from a model) that could have been declared as sublcasses of ``BaseModel``
Take a list of Pydantic ``ModelField``s (from a model) that could have been declared as subclasses of ``BaseModel``
(so, any of them could be a submodel), and generate a set with their models and all the sub-models in the tree.
I.e. if you pass a the fields of a model ``Foo`` (subclass of ``BaseModel``) as ``fields``, and on of them has a
field of type ``Bar`` (also subclass of ``BaseModel``) and that model ``Bar`` has a field of type ``Baz`` (also
@@ -1019,9 +1019,7 @@ def get_annotation_with_constraints(annotation: Any, field_info: FieldInfo) -> T
return constraint_func(**kwargs)
return type_
ans = go(annotation)
return ans, used_constraints
return go(annotation), used_constraints
def normalize_name(name: str) -> str:
+1 -1
View File
@@ -451,7 +451,7 @@ class ValueItems(Representation):
def for_element(self, e: 'IntStr') -> Optional[Union['AbstractSetIntStr', 'MappingIntStrAny']]:
"""
:param e: key or index of element on value
:return: raw values for elemet if self._items is dict and contain needed element
:return: raw values for element if self._items is dict and contain needed element
"""
item = self._items.get(e)
+1 -1
View File
@@ -520,7 +520,7 @@ def test_all_identical():
assert all_identical([a], []) is False, 'Expected iterables with different lengths to evaluate to `False`'
assert (
all_identical([a, [b], b], [a, [b], b]) is False
), 'New list objects are different objects and should therefor not be identical.'
), 'New list objects are different objects and should therefore not be identical.'
def test_undefined_pickle():