Files
pydantic/tests/pyright/pyright_example.py
T
Samuel Colvin 85e4596958 Move settings to pydantic-settings (#4492)
* Move settings to pydantic-settings

* fix docs, remove dotenv

* fix coverage

* removing unused test fixture
2022-09-07 13:05:51 +01:00

26 lines
493 B
Python

"""
This file is used to test pyright's ability to check pydantic code.
"""
from typing import List
from pydantic import BaseModel, Field
class MyModel(BaseModel):
x: str
y: List[int]
m1 = MyModel(x='hello', y=[1, 2, 3])
m2 = MyModel(x='hello') # pyright: ignore
class Knight(BaseModel):
title: str = Field(default='Sir Lancelot') # this is okay
age: int = Field(23) # this works fine at runtime but will case an error for pyright
k = Knight() # pyright: ignore