• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NeuralEnsemble / elephant / 19634252007

24 Nov 2025 12:25PM UTC coverage: 88.22% (-0.04%) from 88.262%
19634252007

Pull #678

github

web-flow
Merge c46228df3 into 539258334
Pull Request #678: Feature/partial First Pydantic Models for parameter validation

540 of 585 new or added lines in 9 files covered. (92.31%)

27 existing lines in 4 files now uncovered.

7234 of 8200 relevant lines covered (88.22%)

5.28 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.48
/elephant/schemas/function_validator.py
1
from functools import wraps
6✔
2
from inspect import signature
6✔
3
from pydantic import BaseModel
6✔
4

5
skip_validation = False
6✔
6

7
def validate_with(model_class: type[BaseModel]):
6✔
8
    """
9
    A decorator that validates the inputs of a function using a Pydantic model.
10
    Works for both positional and keyword arguments.
11
    """
12
    def decorator(func):
6✔
13
        sig = signature(func)
6✔
14

15
        @wraps(func)
6✔
16
        def wrapper(*args, **kwargs):
6✔
17

18
            if not skip_validation:
6✔
19
                # Bind args & kwargs to function parameters
20
                bound = sig.bind_partial(*args, **kwargs)
6✔
21
                bound.apply_defaults()
6✔
22
                data = bound.arguments
6✔
23

24
                # Validate using Pydantic
25
                model_class(**data)
6✔
26

27
            # Call function
28
            return func(*args, **kwargs)
6✔
29
        return wrapper
6✔
30
    return decorator
6✔
31

32
def activate_validation():
6✔
NEW
33
    skip_validation = False
×
34

35
def deactivate_validation():
6✔
NEW
36
    skip_validation = True
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc