mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
Use chain.from_iterable in class_validators.py (#1642)
* Use chain.from_iterable in class_validators.py * fix change Co-authored-by: Samuel Colvin <s@muelcolvin.com>
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
Use `chain.from_iterable` in class_validators.py. This is a faster and more idiomatic way of using `itertools.chain`.
|
||||
Instead of computing all the items in the iterable and storing them in memory, they are computed one-by-one and never
|
||||
stored as a huge list. This can save on both runtime and memory space.
|
||||
@@ -164,11 +164,9 @@ class ValidatorGroup:
|
||||
|
||||
def check_for_unused(self) -> None:
|
||||
unused_validators = set(
|
||||
chain(
|
||||
*[
|
||||
(v.func.__name__ for v in self.validators[f] if v.check_fields)
|
||||
for f in (self.validators.keys() - self.used_validators)
|
||||
]
|
||||
chain.from_iterable(
|
||||
(v.func.__name__ for v in self.validators[f] if v.check_fields)
|
||||
for f in (self.validators.keys() - self.used_validators)
|
||||
)
|
||||
)
|
||||
if unused_validators:
|
||||
|
||||
Reference in New Issue
Block a user