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

Support class fields: classfield() ? #35

Open
smarie opened this issue Oct 15, 2019 · 1 comment · May be fixed by #45
Open

Support class fields: classfield() ? #35

smarie opened this issue Oct 15, 2019 · 1 comment · May be fixed by #45
Labels
enhancement New feature or request

Comments

@smarie
Copy link
Owner

smarie commented Oct 15, 2019

A use case cited in this stackoverflow discussion is to define class fields, so that subclasses are restricted when they override them.

Maybe classfield() could be easily done, similarly to field()

@smarie smarie added the enhancement New feature or request label Oct 15, 2019
@smarie
Copy link
Owner Author

smarie commented Oct 18, 2019

It could be done easily (see branch https://github.com/smarie/python-pyfields/tree/class_fields) but python descriptors do not currently support that __set__ is called for class binding. It is not clear from the doc https://docs.python.org/3/reference/datamodel.html#invoking-descriptors

@smarie smarie linked a pull request Oct 25, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant