Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken examples #753

Merged
merged 2 commits into from Aug 17, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -63,6 +63,11 @@ testcov-compile: build-cython-trace test
@echo "building coverage html"
@coverage html

.PHONY: test-examples
test-examples:
@echo "running examples"
@find docs/examples -type f -name '*.py' | xargs -I'{}' sh -c 'python {} >/dev/null 2>&1 || (echo "{} failed")'

.PHONY: all
all: testcov lint mypy external-mypy

@@ -0,0 +1 @@
fix broken examples in the docs
@@ -9,7 +9,7 @@ class Pets(BaseModel):
print(Pets(__root__=['dog', 'cat']))
# > Pets __root__=['dog', 'cat']

print(Pets.parse_obj(__root__=['dog', 'cat']))
print(Pets.parse_obj(['dog', 'cat']))
# > Pets __root__=['dog', 'cat']

print(Pets.schema())
@@ -30,7 +30,7 @@ class Model(BaseModel):
print(Model(dict_str_float={'a': 1, b'b': 2}).dict_str_float) # > {'a': 1.0, 'b': 2.0}

print(Model(simple_tuple=[1, 2, 3, 4]).simple_tuple) # > (1, 2, 3, 4)
print(Model(tuple_of_different_types=[1, 2, 3, 4]).tuple_of_different_types) # > (1, 2.0, '3', True)
print(Model(tuple_of_different_types=[4, 3, 2, 1]).tuple_of_different_types) # > (4, 3.0, '2', True)

print(Model(sequence_of_ints=[1, 2, 3, 4]).sequence_of_ints) # > [1, 2, 3, 4]
print(Model(sequence_of_ints=(1, 2, 3, 4)).sequence_of_ints) # > (1, 2, 3, 4)
@@ -75,8 +75,8 @@ class Model(BaseModel):
m = Model(
cos_function='math.cos',
path_to_something='/home',
path_to_file='/home/file.py',
path_to_directory='home/projects',
path_to_file='docs/examples/example1.py',
path_to_directory='docs/examples',
short_bytes=b'foo',
strip_bytes=b' bar',
short_str='foo',
@@ -97,6 +97,7 @@ class Model(BaseModel):
url='http://example.com',
password='password',
password_bytes=b'password2',
dsn='postgres://postgres@localhost:5432/foobar',
decimal=Decimal('42.24'),
decimal_positive=Decimal('21.12'),
decimal_negative=Decimal('-21.12'),
@@ -25,11 +25,11 @@ def username_alphanumeric(cls, v):
return v


print(UserModel(name='samuel colvin', password1='zxcvbn', password2='zxcvbn'))
print(UserModel(name='samuel colvin', username='scolvin', password1='zxcvbn', password2='zxcvbn'))
# > UserModel name='Samuel Colvin' password1='zxcvbn' password2='zxcvbn'

try:
UserModel(name='samuel', password1='zxcvbn', password2='zxcvbn2')
UserModel(name='samuel', username='scolvin', password1='zxcvbn', password2='zxcvbn2')
except ValidationError as e:
print(e)
"""
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.