-
-
Notifications
You must be signed in to change notification settings - Fork 485
Add missing methods to Field
.
#100
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
Add missing methods to Field
.
#100
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing!
@@ -69,6 +69,10 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): | |||
def formfield(self, **kwargs) -> FormField: ... | |||
def contribute_to_class(self, cls: Type[Model], name: str, private_only: bool = ...) -> None: ... | |||
def to_python(self, value: Any) -> Any: ... | |||
def get_attname(self) -> str: ... | |||
def value_from_object(self, obj) -> _GT: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you extract this line (whuch causes test failures) in a different PR? It's probably not obvious of a change, and requires a test.
@@ -69,6 +69,10 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): | |||
def formfield(self, **kwargs) -> FormField: ... | |||
def contribute_to_class(self, cls: Type[Model], name: str, private_only: bool = ...) -> None: ... | |||
def to_python(self, value: Any) -> Any: ... | |||
def get_attname(self) -> str: ... | |||
def value_from_object(self, obj) -> _GT: ... | |||
def validate(self, value, model_instance) -> None: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add annotations to the function arguments?
def get_attname(self) -> str: ... | ||
def value_from_object(self, obj) -> _GT: ... | ||
def validate(self, value, model_instance) -> None: ... | ||
def run_validators(self, value) -> None: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, annotations for arguments
I addressed those in #109 |
I noticed the following fields are missing from the base
Field
class:get_attname
(https://github.com/django/django/blob/master/django/db/models/fields/__init__.py#L753)value_from_object
(https://github.com/django/django/blob/master/django/db/models/fields/__init__.py#L892)validate
(https://github.com/django/django/blob/master/django/db/models/fields/__init__.py#L592)run_validators
(https://github.com/django/django/blob/master/django/db/models/fields/__init__.py#L576)