-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Custom classes inheriting Entity cannot be constructed from entities #396
Comments
@ebbixby Why do you need to use Just use ent = Foo(dataset=dataset) and go on your merry way? The constructor takes: def __init__(self, dataset=None, kind=None, exclude_from_indexes=()):
super(Entity, self).__init__() It's not typical that a constructor accepts an entity of its own type, though in some cases makes sense. I am inclined to close this as "Working as Intended" but maybe I am missing something? FWIW We are always discussing removing |
My mistake. I meant It would be very desirable to get an entity back from a query or fetch by key and immediately cast it to an object that inherits entity. Right? |
Yes, that does seem more reasonable. This seems to fall under the umbrella of building an It's unclear that built-in extensibility should also be at this low-level API. I'm inclined to say it should not and that we are happy to support use-cases like this until A change that comes to mind which could make class Entity(object):
def __init__(self, dataset=None, kind=None, exclude_from_indexes=(), data=None):
self.data = data or {}
def __getitem__(self, name):
return self.data[name] @tseaver WDYT? |
I'm ghost. Just consolidating github accounts. |
Just wanna throw my support behind |
I don't get the issue behind subclassing |
Ditto here. Closing since new API (hopefully) reduces friction. |
Co-authored-by: Anthonios Partheniou <[email protected]>
* chore: Update gapic-generator-python to v1.8.4 PiperOrigin-RevId: 507808936 Source-Link: googleapis/googleapis@64cf849 Source-Link: googleapis/googleapis-gen@53c48ca Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTNjNDhjYWMxNTNkM2IzN2YzZDJjMmRlYzQ4MzBjZmQ5MWVjNDE1MyJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
* chore: add release-please manifest * linter * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Source-Link: googleapis/synthtool@5f2a608 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:8555f0e37e6261408f792bfd6635102d2da5ad73f8f09bcb24f25e6afb5fac97 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <[email protected]>
Source-Link: googleapis/synthtool@6fab84a Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe
Source-Link: https://togithub.com/googleapis/synthtool/commit/dede53ff326079b457cfb1aae5bbdc82cbb51dc3 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:fac304457974bb530cc5396abd4ab25d26a469cd3bc97cbfb18c8d4324c584eb
* feat: add interoperable symmetric encryption system PiperOrigin-RevId: 544660001 Source-Link: googleapis/googleapis@511319c Source-Link: googleapis/googleapis-gen@812def9 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODEyZGVmOTU5NGU5ZmEwODc2ZTBlMDExOTUxZGMwYmVjN2EwYTVmZCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <[email protected]>
* chore: Update gapic-generator-python to v1.11.9 PiperOrigin-RevId: 574520922 Source-Link: googleapis/googleapis@5183984 Source-Link: googleapis/googleapis-gen@a59af19 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYTU5YWYxOWQ0YWM2NTA5ZmFlZGYxY2MzOTAyOTE0MWI2YTViODk2OCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * update post processor image; remove unused files * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
* chore(deps): update all dependencies * revert protobuf Co-authored-by: Anthonios Partheniou <[email protected]>
Currently the following doesn't work:
This is inconsistent with
Entity
inheritingdict
. Besides style issues, I would think sub-classingEntity
would be the preferred way to introduce custom behavior, or enforce an entity schema.Current workaround is:
The text was updated successfully, but these errors were encountered: