aromanovich / jsl

A Python DSL for describing JSON schemas
http://jsl.readthedocs.org/
Other
218 stars 21 forks source link

Document base class should allow all property names with best effort #21

Open sseg opened 8 years ago

sseg commented 8 years ago

Although the name argument for fields allows any name to be assigned to a property, the Document class should at least try to avoid polluting the namespace of schemas.

Unknowingly overwriting a class attribute can sometimes produce confusing errors. TypeError: 'StringField' object is not callable is thrown from the class definition:

class Schema(Document):
    walk = StringField()

Internal methods of Document and it's parents could be prefixed with an underscore to at least try to preserve more of the namespace for users and reduce the cases where an alias must be invoked.

aromanovich commented 8 years ago

Unfortunately, Document's methods are public and documented and can not be renamed without breaking backwards compatibility. I'll consider renaming them in the next major version.