Type-safe data validation and mocking for Python dataclasses and Pydantic models
Project description
mocksmith
Type-safe data validation with automatic mock generation for Python dataclasses and Pydantic models. Build robust data models with database-aware validation and generate realistic test data with a single decorator.
Features
- Type-safe database columns: Define database columns with proper validation
- Serialization/Deserialization: Automatic conversion between Python and SQL types
- Dataclass Integration: Full support for Python dataclasses with validation
- Pydantic Integration: First-class Pydantic support with automatic validation
- Clean API: Simple, intuitive interface for both Pydantic AND dataclasses - just
name: Varchar(50) - Comprehensive Types: STRING (VARCHAR, CHAR, TEXT), NUMERIC (INTEGER, DECIMAL, FLOAT), TEMPORAL (DATE, TIME, TIMESTAMP), and more
- Mock Data Generation: Built-in mock/fake data generation for testing with
@mockabledecorator - Constrained Types: Support for min/max constraints on numeric types -
price: PositiveMoney(),age: Integer(ge=0, le=120)
Why mocksmith?
Before (Traditional Approach)
from typing import Annotated
from pydantic import BaseModel, Field, validator
from decimal import Decimal
class Product(BaseModel):
name: Annotated[str, Field(max_length=100)]
price: Annotated[Decimal, Field(decimal_places=2, max_digits=10)]
in_stock: bool = True
@validator('price')
def validate_price(cls, v):
if v < 0:
raise ValueError('Price must be non-negative')
return v
After (With mocksmith)
from pydantic import BaseModel
from mocksmith import Varchar, Money, Boolean
class Product(BaseModel):
name: Varchar(100) # Enforces VARCHAR(100) constraint
price: Money() # Decimal(19,4) - use PositiveMoney() for price > 0
in_stock: Boolean() = True # Flexible boolean parsing
✨ Benefits:
- Same clean syntax for both Pydantic and dataclasses
- Automatic SQL constraint validation
- Type conversion (string "99.99" → Decimal)
- Better IDE support and type hints
- Write once, use with either framework
Installation
# Standard installation (includes mock generation)
pip install mocksmith
# With Pydantic validation support (recommended)
pip install "mocksmith[pydantic]"
The standard installation includes Faker for mock data generation and custom validation logic. Adding Pydantic provides better performance and integration with Pydantic types.
Import Structure
The library organizes types into two categories:
Core Database Types
Core database types are available directly from the main package:
from mocksmith import (
# String types
VARCHAR, CHAR, TEXT, Varchar, Char, Text,
# Numeric types
INTEGER, DECIMAL, FLOAT, Integer, DecimalType, Float,
# Temporal types
DATE, TIME, TIMESTAMP, Date, Time, Timestamp,
# Other types
BOOLEAN, BINARY, Boolean, Binary,
# Constrained types
PositiveInteger, NonNegativeInteger, NegativeInteger, NonPositiveInteger,
Money, PositiveMoney, NonNegativeMoney, ConstrainedMoney,
ConstrainedDecimal, ConstrainedFloat
)
Specialized Types
Specialized types for common use cases are available from the specialized submodule:
from mocksmith.specialized import (
# Geographic types
CountryCode, # ISO 3166-1 alpha-2 country codes
City, # City names
State, # State/province names
ZipCode, # Postal codes
# Contact types
PhoneNumber, # Phone numbers
)
Note: For email and web types, use Pydantic's built-in types instead:
- Email → Use
pydantic.EmailStr - URL → Use
pydantic.HttpUrlorpydantic.AnyUrl - IP addresses → Use
pydantic.IPvAnyAddress,pydantic.IPv4Address, orpydantic.IPv6Address
This separation keeps the main namespace clean and makes it clear which types are fundamental database types versus application-specific types.
Quick Start
Clean Interface (Works with both Pydantic and Dataclasses!) ✨
from pydantic import BaseModel
from mocksmith import Varchar, Integer, Boolean, Money
class User(BaseModel):
id: Integer()
username: Varchar(50)
email: Varchar(255)
is_active: Boolean() = True
balance: Money() = "0.00"
# Automatic validation and type conversion
user = User(
id=1,
username="john_doe",
email="john@example.com",
is_active="yes", # Converts to True
balance="1234.56" # Converts to Decimal('1234.56')
)
The same syntax works with dataclasses! See full examples:
examples/pydantic_example.py- Comprehensive Pydantic examples with all featuresexamples/dataclass_example.py- Comprehensive dataclass examples with all featuresexamples/pydantic_mock_example.py- Mock data generation with Pydantic modelsexamples/dataclass_mock_example.py- Mock data generation with dataclassesexamples/constrained_types_example.py- Constrained types with validation and mock generation
Common Use Cases
E-commerce Product Model:
from pydantic import BaseModel
from mocksmith import Varchar, Text, Money, Boolean, Timestamp
class Product(BaseModel):
sku: Varchar(20)
name: Varchar(100)
description: Text()
price: Money()
in_stock: Boolean() = True
created_at: Timestamp()
User Account with Constraints:
from mocksmith import Integer, PositiveInteger, NonNegativeInteger
class UserAccount(BaseModel):
user_id: PositiveInteger()
age: Integer(ge=13, le=120)
balance_cents: NonNegativeInteger()
See complete working examples:
examples/- All example files with detailed documentationexamples/pydantic_example.py- All features including constraintsexamples/dataclass_example.py- All features including constraints
Mock Data Generation
Generate realistic test data automatically with the @mockable decorator:
from dataclasses import dataclass
from mocksmith import Varchar, Integer, Date, mockable
from mocksmith.specialized import PhoneNumber, CountryCode
@mockable
@dataclass
class User:
id: Integer()
username: Varchar(50)
phone: PhoneNumber()
country: CountryCode()
birth_date: Date()
# Generate mock instances
user = User.mock()
print(user.username) # "Christina Wells"
print(user.phone) # "(555) 123-4567"
print(user.country) # "US"
# With overrides
user = User.mock(username="test_user", country="GB")
# Using builder pattern
user = (User.mock_builder()
.with_username("john_doe")
.with_country("CA")
.build())
The same @mockable decorator works with Pydantic models! Mock generation:
- Respects all field constraints (length, format, etc.)
- Generates appropriate mock data for each type
- Supports specialized types with realistic data
- Works with both dataclasses and Pydantic models
- Automatically handles Python Enum types with random value selection
See mock examples:
examples/dataclass_mock_example.py- Complete mock examples with dataclasses including enum supportexamples/pydantic_mock_example.py- Complete mock examples with Pydantic including enum support and built-in types
Clean Annotation Interface
The library provides a clean, Pythonic interface for defining database types that works with both Pydantic and dataclasses:
# Works with Pydantic
from pydantic import BaseModel
from mocksmith import Varchar, Integer, Money, Date, Boolean, Text
class Product(BaseModel):
sku: Varchar(20)
name: Varchar(100)
description: Text()
price: Money() # Alias for Decimal(19, 4)
in_stock: Boolean()
# Also works with dataclasses!
from dataclasses import dataclass
from mocksmith.dataclass_integration import validate_dataclass
@validate_dataclass
@dataclass
class Product:
sku: Varchar(20)
name: Varchar(100)
description: Text()
price: Money() = Decimal("0.00")
in_stock: Boolean() = True
# Instead of the verbose way:
# from typing import Annotated
# from mocksmith.types.string import VARCHAR
# from mocksmith.types.numeric import DECIMAL
# class Product:
# sku: Annotated[str, VARCHAR(20)]
# name: Annotated[str, VARCHAR(100)]
# price: Annotated[Decimal, DECIMAL(19, 4)]
Available Clean Types:
String Types:
Varchar(length)→ Variable-length stringChar(length)→ Fixed-length stringText()→ Large text fieldString→ Alias for Varchar
Numeric Types:
Integer()→ 32-bit integerBigInt()→ 64-bit integerSmallInt()→ 16-bit integerTinyInt()→ 8-bit integerDecimalType(precision, scale)→ Fixed-point decimalNumeric(precision, scale)→ Alias for DecimalTypeMoney()→ Alias for Decimal(19, 4)Float()→ Floating point (generates FLOAT SQL type)Real()→ Floating point (generates REAL SQL type, typically single precision in SQL)Double()→ Double precision
Constrained Numeric Types:
PositiveInteger()→ Integer > 0NegativeInteger()→ Integer < 0NonNegativeInteger()→ Integer ≥ 0NonPositiveInteger()→ Integer ≤ 0ConstrainedInteger(ge=x, le=y, multiple_of=z)→ Custom constraintsConstrainedBigInt(...)→ Constrained 64-bit integerConstrainedSmallInt(...)→ Constrained 16-bit integerConstrainedTinyInt(...)→ Constrained 8-bit integer
Temporal Types:
Date()→ Date onlyTime()→ Time onlyTimestamp()→ Date and time with timezoneDateTime()→ Date and time without timezone
Other Types:
Boolean()/Bool()→ Boolean with flexible parsingBinary(length)→ Fixed binaryVarBinary(max_length)→ Variable binaryBlob()→ Large binary object
Pydantic Integration Features
Pydantic Built-in Types Support
Mocksmith now supports automatic mock generation for Pydantic's built-in types:
from pydantic import BaseModel, EmailStr, HttpUrl, IPvAnyAddress, conint, constr
from mocksmith import mockable
@mockable
class ServerConfig(BaseModel):
hostname: constr(min_length=1, max_length=253)
ip_address: IPvAnyAddress
port: conint(ge=1, le=65535)
api_url: HttpUrl
admin_email: EmailStr
# Generate mock with Pydantic types
config = ServerConfig.mock()
print(config.ip_address) # IPv4Address('192.168.1.100')
print(config.api_url) # https://example.com
print(config.admin_email) # user@example.com
Tip: For types that have Pydantic equivalents, prefer using Pydantic's built-in types:
- Use
EmailStrinstead ofmocksmith.specialized.Email - Use
HttpUrlorAnyUrlinstead ofmocksmith.specialized.URL - Use
IPvAnyAddress,IPv4Address, orIPv6Addressfor IP addresses
Using Pydantic Types in Dataclasses
While Pydantic types can be used as type annotations in dataclasses, there are important limitations:
from dataclasses import dataclass
from pydantic import EmailStr, HttpUrl, conint
@dataclass
class ServerConfig:
hostname: str
email: EmailStr # Works as type hint only
port: conint(ge=1, le=65535) # No validation!
# This creates an instance WITHOUT validation
server = ServerConfig(
hostname="api.example.com",
email="invalid-email", # Not validated!
port=99999 # Out of range but accepted!
)
Key Points:
- Pydantic types in dataclasses serve as type hints only
- No automatic validation occurs
- Mock generation works but produces regular Python types (str, int, etc.)
- For validation, use Pydantic's BaseModel instead
See the Pydantic types limitations section in examples/dataclass_example.py for a complete comparison.
Supported Pydantic Types for Mock Generation
The @mockable decorator supports automatic mock generation for the following Pydantic types:
Network Types
HttpUrl- Generates valid HTTP/HTTPS URLsAnyHttpUrl- Generates any HTTP scheme URLsEmailStr- Generates valid email addressesIPvAnyAddress- Generates IPv4 or IPv6 addresses (80% IPv4, 20% IPv6)IPvAnyInterface- Generates IP addresses with CIDR notationIPvAnyNetwork- Generates IP network addresses
Numeric Types
PositiveInt- Integers > 0NegativeInt- Integers < 0NonNegativeInt- Integers >= 0NonPositiveInt- Integers <= 0PositiveFloat- Floats > 0NegativeFloat- Floats < 0NonNegativeFloat- Floats >= 0NonPositiveFloat- Floats <= 0
String/Identifier Types
UUID1,UUID3,UUID4,UUID5- Generates UUIDs (currently all as UUID4)SecretStr- Generates password-like stringsJson- Generates valid JSON strings
Date/Time Types
FutureDate- Generates dates in the futurePastDate- Generates dates in the pastFutureDatetime- Generates datetimes in the futurePastDatetime- Generates datetimes in the past
Constraint Types
conint(ge=1, le=100)- Integers with min/max constraintsconfloat(ge=0.0, le=1.0)- Floats with min/max constraintsconstr(min_length=1, max_length=50)- Strings with length constraintsconstr(pattern=r"^[A-Z]{3}[0-9]{3}$")- Strings matching regex patterns (limited support)conlist(item_type, min_length=1, max_length=10)- Lists with constraints
Example Usage
from pydantic import BaseModel, EmailStr, HttpUrl, conint, PositiveInt
from mocksmith import mockable
@mockable
class UserProfile(BaseModel):
user_id: PositiveInt
email: EmailStr
website: HttpUrl
age: conint(ge=18, le=120)
# Generate mock data
user = UserProfile.mock()
print(user.email) # "john.doe@example.com"
print(user.website) # "https://example.com"
print(user.age) # 42 (between 18-120)
Note: When using Pydantic types in dataclasses (not BaseModel), the types work as annotations only without validation. The mock generation still works but produces regular Python types.
Handling Unsupported Types
When @mockable encounters an unsupported type, it attempts to handle it intelligently:
- Common types (Path, Set, FrozenSet) - Now supported with appropriate mock values
- Auto-instantiable types - Tries to create instances with
(),None,"", or0 - Truly unsupported types - Returns
Nonewith a warning to help identify gaps in type support
Newly Supported Types
from dataclasses import dataclass
from pathlib import Path
from typing import Set, FrozenSet
from mocksmith import mockable
@mockable
@dataclass
class Config:
config_path: Path # ✓ Generates Path('/tmp/mock_file.txt')
data_dir: Path # ✓ Smart naming: Path('/tmp/mock_directory')
tags: Set[str] # ✓ Generates {'tag1', 'tag2', ...}
frozen_tags: FrozenSet[int] # ✓ Generates frozenset({1, 2, 3})
config = Config.mock()
# All fields get appropriate mock values!
Warning System
class CustomType:
def __init__(self, required_arg):
# Cannot be auto-instantiated
pass
@mockable
@dataclass
class Example:
name: str # ✓ Supported
custom_required: CustomType # ⚠️ Warning issued, returns None
custom_optional: Optional[CustomType] = None # ⚠️ Warning issued (if attempted), returns None
# Console output:
# UserWarning: mocksmith: Unsupported type 'CustomType' for field 'custom_required'.
# Returning None. Consider making this field Optional or providing a mock override.
Important Notes:
- All unsupported types trigger warnings - This helps identify gaps in mocksmith's type support
- Warnings help improve mocksmith - If you encounter warnings, please file an issue on GitHub
- Optional fields - May show warnings ~80% of the time (when generation is attempted)
- Override unsupported types - Use
mock()with overrides:Example.mock(custom_required=CustomType('value')) - Pydantic models - Make unsupported fields
Optionalto avoid validation errors
Optional Fields Pattern
Python's Optional type indicates fields that can be None:
from typing import Optional
from pydantic import BaseModel
from mocksmith import Varchar, Integer, Text
class Example(BaseModel):
# Required field
required_field: Varchar(50)
# Optional field (can be None)
optional_field: Optional[Varchar(50)] = None
# Field with default value
status: Varchar(20) = "active"
Best Practice: For optional fields, use Optional[Type] with = None:
bio: Optional[Text()] = None # Clear and explicit
phone: Optional[Varchar(20)] = None # Optional field with no default
Automatic Type Conversion
from pydantic import BaseModel
from mocksmith import Money, Boolean, Date, Timestamp
class Order(BaseModel):
# String to Decimal conversion
total: Money()
# Flexible boolean parsing
is_paid: Boolean()
# String to date conversion
order_date: Date()
# String to datetime conversion
created_at: Timestamp(with_timezone=False)
# All these string values are automatically converted
order = Order(
total="99.99", # → Decimal('99.99')
is_paid="yes", # → True
order_date="2023-12-15", # → date(2023, 12, 15)
created_at="2023-12-15T10:30:00" # → datetime
)
Field Validation with Pydantic
from pydantic import BaseModel, field_validator
from mocksmith import Varchar, Integer, Money
class Product(BaseModel):
name: Varchar(50)
price: Money()
quantity: Integer()
@field_validator('price')
def price_must_be_positive(cls, v):
if v <= 0:
raise ValueError('Price must be positive')
return v
@field_validator('quantity')
def quantity_non_negative(cls, v):
if v < 0:
raise ValueError('Quantity cannot be negative')
return v
Model Configuration
from pydantic import BaseModel, ConfigDict
from mocksmith import Varchar, Money, Timestamp
class StrictModel(BaseModel):
model_config = ConfigDict(
# Validate on assignment
validate_assignment=True,
# Use Enum values
use_enum_values=True,
# Custom JSON encoders
json_encoders={
Decimal: str,
datetime: lambda v: v.isoformat()
}
)
name: Varchar(100)
price: Money()
updated_at: Timestamp()
Working Examples
For complete working examples, see the examples/ directory:
-
dataclass_example.py- Comprehensive dataclass examples including:- All data types (String, Numeric, Date/Time, Binary, Boolean)
- Constrained numeric types (PositiveInteger, NonNegativeInteger, etc.)
- Custom constraints (min_value, max_value, multiple_of)
- TINYINT usage for small bounded values
- REAL vs FLOAT distinction
- SQL serialization
- Validation and error handling
-
pydantic_example.py- Comprehensive Pydantic examples including:- All data types with automatic validation
- Field validators and computed properties
- Constrained types with complex business logic
- JSON serialization with custom encoders
-
dataclass_mock_example.py- Mock data generation examples:- Using
@mockabledecorator with dataclasses - Generating mock instances with
.mock() - Override specific fields
- Type-safe builder pattern
- Specialized types (Email, CountryCode, etc.)
- Using
-
pydantic_mock_example.py- Mock data generation with Pydantic:- Using
@mockabledecorator with Pydantic models - Same mock API as dataclasses
- Automatic validation of generated data
- Specialized types with DBTypeValidator
- Model configuration and validation on assignment
- TINYINT and REAL type usage
- Boolean type conversions
- Using
-
constrained_types_example.py- Constrained types with validation:- PositiveMoney, NonNegativeMoney, ConstrainedMoney usage
- ConstrainedDecimal with precision and range constraints
- ConstrainedFloat for percentages and probabilities
- Mock generation respecting all constraints
- Validation examples showing error handling
- Builder pattern with constrained types
Example: E-commerce Order System
from dataclasses import dataclass
from typing import Optional
from datetime import datetime, date
from decimal import Decimal
from mocksmith import Varchar, Integer, Date, DecimalType, Text, BigInt, Timestamp
from mocksmith.dataclass_integration import validate_dataclass
@validate_dataclass
@dataclass
class Customer:
customer_id: Integer()
first_name: Varchar(50)
last_name: Varchar(50)
email: Varchar(100)
phone: Optional[Varchar(20)]
date_of_birth: Optional[Date()]
@validate_dataclass
@dataclass
class Order:
order_id: BigInt()
customer_id: Integer()
order_date: Timestamp(with_timezone=False)
total_amount: DecimalType(12, 2)
status: Varchar(20)
notes: Optional[Text()]
# Create instances
customer = Customer(
customer_id=1,
first_name="Jane",
last_name="Smith",
email="jane.smith@email.com",
phone="+1-555-0123",
date_of_birth=date(1990, 5, 15)
)
order = Order(
order_id=1001,
customer_id=1,
order_date=datetime(2023, 12, 15, 14, 30, 0),
total_amount=Decimal("299.99"),
status="pending",
notes="Rush delivery requested"
)
# Convert to SQL-ready format
print(order.to_sql_dict())
For more complete examples including financial systems, authentication, and SQL testing integration,
see the examples/ directory.
Default Value Validation in Dataclasses
When using @validate_dataclass, default values are validated when an instance is created, not when the class is defined:
@validate_dataclass
@dataclass
class Config:
# This class definition succeeds even with invalid default
hour: SmallInt(ge=0, le=23) = 24
# But creating an instance fails with validation error
try:
config = Config() # Raises ValueError: Value 24 exceeds maximum 23
except ValueError as e:
print(f"Validation error: {e}")
# You can override with valid values
config = Config(hour=12) # Works fine
This behavior is consistent with Python's normal evaluation of default values and ensures that validation runs for all values, including defaults.
Advanced Features
Custom Validation
@validate_dataclass
@dataclass
class CustomProduct:
sku: Annotated[str, VARCHAR(20)] # Required field
name: Annotated[str, VARCHAR(100)] # Required field
description: Annotated[Optional[str], VARCHAR(500)] # Optional field
Working with Different Types
# Integer types with range validation
small_value = SMALLINT()
small_value.validate(32767) # OK
# small_value.validate(32768) # Raises ValueError - out of range
# Decimal with precision
money = DECIMAL(19, 4)
money.validate("12345.6789") # OK
# money.validate("12345.67890") # Raises ValueError - too many decimal places
# Time with precision
timestamp = TIMESTAMP(precision=0) # No fractional seconds
timestamp.validate("2023-12-15T10:30:45.123456") # Microseconds will be truncated
# Boolean accepts various formats
bool_type = BOOLEAN()
bool_type.deserialize("yes") # True
bool_type.deserialize("1") # True
bool_type.deserialize("false") # False
bool_type.deserialize(0) # False
Constrained Numeric Types
The library provides specialized numeric types with built-in constraints for common validation scenarios:
from mocksmith import Integer, PositiveInteger, NonNegativeInteger
# Enhanced Integer functions - no constraints = standard type
id: Integer() # Standard 32-bit integer
quantity: Integer(ge=0) # With constraints (same as NonNegativeInteger)
discount: Integer(ge=0, le=100) # Percentage 0-100
price: Integer(gt=0) # Same as PositiveInteger()
# Specialized constraint types
id: PositiveInteger() # > 0
quantity: NonNegativeInteger() # >= 0
For complete examples with both dataclasses and Pydantic, see:
examples/dataclass_example.py- All constraint examples with dataclassesexamples/pydantic_example.py- All constraint examples with Pydantic
Available Constraint Options:
# Enhanced Integer functions - no constraints = standard type
Integer() # Standard 32-bit integer
Integer(ge=0) # With constraints
Integer(gt=0) # Shortcut for > 0
BigInt() # Standard 64-bit integer
BigInt(ge=0, le=1000000) # With constraints
SmallInt() # Standard 16-bit integer
SmallInt(multiple_of=10) # With constraints
# Specialized constraint types
PositiveInteger() # > 0
NegativeInteger() # < 0
NonNegativeInteger() # >= 0
NonPositiveInteger() # <= 0
# Full constraint options
Integer(
gt=10, # Value must be greater than 10
ge=10, # Value must be greater than or equal to 10
lt=100, # Value must be less than 100
le=100, # Value must be less than or equal to 100
multiple_of=5, # Must be divisible by this
)
Constrained Money and Decimal Types
mocksmith provides constrained versions of Money and Decimal types using Pydantic's constraint system:
from mocksmith import (
ConstrainedMoney, PositiveMoney, NonNegativeMoney,
ConstrainedDecimal, ConstrainedFloat
)
# Money with constraints
price: PositiveMoney() # > 0
balance: NonNegativeMoney() # >= 0
discount: ConstrainedMoney(ge=0, le=100) # 0-100 range
payment: ConstrainedMoney(gt=0, le=10000) # 0 < payment <= 10000
# Decimal with precision and constraints
weight: ConstrainedDecimal(10, 2, gt=0) # Positive weight, max 10 digits, 2 decimal places
temperature: ConstrainedDecimal(5, 2, ge=-273.15) # Above absolute zero
# Float with constraints
percentage: ConstrainedFloat(ge=0.0, le=1.0) # 0-1 range
rate: ConstrainedFloat(gt=0, lt=0.5) # 0 < rate < 0.5
These constrained types:
- Work seamlessly with Pydantic validation
- Generate appropriate mock data respecting constraints
- Provide the same clean API as other mocksmith types
- Fall back gracefully if Pydantic is not available
Example Usage:
from pydantic import BaseModel
from mocksmith import mockable, PositiveMoney, NonNegativeMoney, ConstrainedMoney, ConstrainedFloat
@mockable
class Order(BaseModel):
subtotal: PositiveMoney() # Must be > 0
discount: ConstrainedMoney(ge=0, le=50) # 0-50 range
tax: NonNegativeMoney() # >= 0
discount_rate: ConstrainedFloat(ge=0, le=0.3) # 0-30%
# Validation works
order = Order(
subtotal="100.00", # ✓ Converts to Decimal
discount="25.00", # ✓ Within 0-50 range
tax="8.50", # ✓ Non-negative
discount_rate=0.15 # ✓ 15% is within 0-30%
)
# Mock generation respects constraints
mock_order = Order.mock()
assert mock_order.subtotal > 0
assert 0 <= mock_order.discount <= 50
assert mock_order.tax >= 0
assert 0 <= mock_order.discount_rate <= 0.3
Development
- Clone the repository:
git clone https://github.com/gurmeetsaran/mocksmith.git
cd mocksmith
- Install Poetry (if not already installed):
curl -sSL https://install.python-poetry.org | python3 -
- Install dependencies:
poetry install
- Set up pre-commit hooks:
poetry run pre-commit install
- Run tests:
make test
Development Commands
make lint- Run linting (ruff + pyright)make format- Format code (black + isort + ruff fix)make test- Run testsmake test-cov- Run tests with coveragemake check-all- Run all checks (lint + format check + tests)make check-consistency- Verify pre-commit, Makefile, and CI are in sync
Ensuring Consistency
To ensure your development environment matches CI/CD:
# Check that pre-commit hooks match Makefile and GitHub Actions
make check-consistency
This will verify that all tools (black, isort, ruff, pyright) are configured consistently across:
- Pre-commit hooks (
.pre-commit-config.yaml) - Makefile commands
- GitHub Actions workflows
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mocksmith-3.0.3.tar.gz.
File metadata
- Download URL: mocksmith-3.0.3.tar.gz
- Upload date:
- Size: 45.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de9658e9c174d90990ff98d14f86f433b897db377a860047116e2cad2f00819a
|
|
| MD5 |
9981da05a8a4f425547d596bb2af4541
|
|
| BLAKE2b-256 |
03aa67d63808ba142dbfcc6b1512ccd3b93481a8edaceb86508f8a3cf10fc925
|
Provenance
The following attestation bundles were made for mocksmith-3.0.3.tar.gz:
Publisher:
release.yml on gurmeetsaran/mocksmith
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mocksmith-3.0.3.tar.gz -
Subject digest:
de9658e9c174d90990ff98d14f86f433b897db377a860047116e2cad2f00819a - Sigstore transparency entry: 262679167
- Sigstore integration time:
-
Permalink:
gurmeetsaran/mocksmith@202c3e854ebce9a458900352f969ce7203d5044e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/gurmeetsaran
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@202c3e854ebce9a458900352f969ce7203d5044e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file mocksmith-3.0.3-py3-none-any.whl.
File metadata
- Download URL: mocksmith-3.0.3-py3-none-any.whl
- Upload date:
- Size: 44.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da56925f75e1a16342fc492bd96372b6fd6a40b14180c8ed74dbd060e6eab7da
|
|
| MD5 |
fa28d3b05b3d4ab16640b187aeffaccd
|
|
| BLAKE2b-256 |
225fb2a74f015a9b44063bf6c782acdc86fdd6d4d1b3cc82a1f269fef5225c0b
|
Provenance
The following attestation bundles were made for mocksmith-3.0.3-py3-none-any.whl:
Publisher:
release.yml on gurmeetsaran/mocksmith
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mocksmith-3.0.3-py3-none-any.whl -
Subject digest:
da56925f75e1a16342fc492bd96372b6fd6a40b14180c8ed74dbd060e6eab7da - Sigstore transparency entry: 262679184
- Sigstore integration time:
-
Permalink:
gurmeetsaran/mocksmith@202c3e854ebce9a458900352f969ce7203d5044e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/gurmeetsaran
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@202c3e854ebce9a458900352f969ce7203d5044e -
Trigger Event:
workflow_dispatch
-
Statement type: