flywhl / flywhl/vyper

feat: first-class data constraints (and ranges)

Open
#3 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

**BEFORE**:
```python
class Experiment:
temperature: float in (0, 100) # °C
ph: float in [0, 14]
concentration: float > 0
sample_size: int % 2 == 0 # Must be even
```

**AFTER**:
```python
# After (transpiled.py)
from vyper.validation import Range, InRange, validate_unit
from pydantic import BaseModel, validator
from typing import Any

class ChemicalReaction(BaseModel):
temperature: float
concentration: float
catalyst_amount: float

@validator('temperature')
def validate_temperature(cls, v):
if not 0 < v < 100:
raise ValueError(f"Temperature {v}°C not in range (0,100)")
return v

@validator('concentration')
def validate_concentration(cls, v):
if not v > 0:
raise ValueError("Concentration must be positive")
validate_unit(v, 'mg/L')
return v

@validator('catalyst_amount')
def validate_catalyst(cls, v):
if not 0.1 <= v <= 1.0:
raise ValueError("Catalyst amount must be between 0.1 and 1.0 mg")
validate_unit(v, 'mg')
return v
```

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue names no source files, tests, or entry points; start by tracing how annotated class fields are parsed and transpiled to the shown Python output. Define the supported constraint syntax and validation behavior, then add tests covering ranges, comparisons, units, and errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.