Skip to content

Instantly share code, notes, and snippets.

@gidgid
Last active October 4, 2020 08:44
Show Gist options
  • Save gidgid/aae07e53c1b784da3fd0b421f9d3dad0 to your computer and use it in GitHub Desktop.
Save gidgid/aae07e53c1b784da3fd0b421f9d3dad0 to your computer and use it in GitHub Desktop.
Camelcase names are weird in Python
from pydantic import BaseModel
class Item(BaseModel):
id: str # 1
isAvailable: bool # 2
def test_does_it_look_pythonic_to_you():
item = Item(id='test-item-id', isAvailable=True) # 3
assert item.isAvailable is True # 3
external_input = {'id': 'new-test-id', 'isAvailable': False}
item = Item(**external_input) # 4
assert item.isAvailable is False # 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment