From 90080ba0de12e561b138ce221b5a67dcd932ab3e Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 4 Sep 2021 00:05:36 +0200 Subject: [PATCH] Fix typos discovered by codespell (#3096) --- docs/usage/models.md | 2 +- docs/usage/settings.md | 2 +- pydantic/datetime_parse.py | 2 +- pydantic/fields.py | 2 +- pydantic/generics.py | 2 +- pydantic/schema.py | 6 ++---- pydantic/utils.py | 2 +- tests/test_utils.py | 2 +- 8 files changed, 9 insertions(+), 11 deletions(-) diff --git a/docs/usage/models.md b/docs/usage/models.md index 9fbb70d..a0f6538 100644 --- a/docs/usage/models.md +++ b/docs/usage/models.md @@ -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 diff --git a/docs/usage/settings.md b/docs/usage/settings.md index afca230..b4a47ea 100644 --- a/docs/usage/settings.md +++ b/docs/usage/settings.md @@ -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 diff --git a/pydantic/datetime_parse.py b/pydantic/datetime_parse.py index 59466c1..e4dff67 100644 --- a/pydantic/datetime_parse.py +++ b/pydantic/datetime_parse.py @@ -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() diff --git a/pydantic/fields.py b/pydantic/fields.py index 780b9a0..93887e8 100644 --- a/pydantic/fields.py +++ b/pydantic/fields.py @@ -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 diff --git a/pydantic/generics.py b/pydantic/generics.py index 7d0635a..c14da4e 100644 --- a/pydantic/generics.py +++ b/pydantic/generics.py @@ -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. diff --git a/pydantic/schema.py b/pydantic/schema.py index e7ecde1..333b1ce 100644 --- a/pydantic/schema.py +++ b/pydantic/schema.py @@ -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: diff --git a/pydantic/utils.py b/pydantic/utils.py index 8660c74..6a6fadb 100644 --- a/pydantic/utils.py +++ b/pydantic/utils.py @@ -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) diff --git a/tests/test_utils.py b/tests/test_utils.py index 5827735..9c0ab4f 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -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():