Last active
October 2, 2020 11:36
-
-
Save gidgid/9a6065abccee8fbf73e9a7abcdfac5db to your computer and use it in GitHub Desktop.
Inconsistant Naming Conventions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pydantic import BaseModel | |
class CamelCaseItem(BaseModel): | |
id: str | |
isAvailable: bool | |
def test_python_camel_case_names_are_weird_in_python(): | |
item = CamelCaseItem(id='test-item-id', isAvailable=True) | |
assert item.isAvailable is True | |
class ItemWithHiddenId(BaseModel): | |
_id: str | |
is_available: bool | |
def test_pydantic_hides_names_with_preceding_underscores(): | |
item = ItemWithHiddenId(_id='test-item-id', is_available=True) | |
assert hasattr(item, '_id') is False | |
assert item.dict().get('_id') is None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment