GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||
GeezerVison is showing github.com — feat: add custom __dir__ for messages and message classes by software-dov · Pull Request #289 · googleapis/proto-plus-python
This repository was archived by the owner on Feb 23, 2026. It is now read-only.
Conversation
Contributor
During development, it can be convenient to inspect objects and types Because proto-plus messages wrap their fields using getattr, the
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsDuring development, it can be convenient to inspect objects and types directly to determine what methods and attributes they have using the dir() builtin command in a debugger or a REPL. Because proto-plus messages wrap their fields using __getattr__, the proto fields are not visible by default and must be explicitly exposed to dir().
software-dov
requested review from
a team,
atulep,
busunkim96,
parthea and
tswast
|
There was an error while loading. Please reload this page.
Codecov Report
@@ Coverage Diff @@ ## main #289 +/- ## ======================================== Coverage ? 100.00% ======================================== Files ? 22 Lines ? 983 Branches ? 219 ======================================== Hits ? 983 Misses ? 0 Partials ? 0 Continue to review full report at Codecov.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| names = {f_name for f_name in self._meta.fields.keys()} | ||
| names.update(m.name for m in desc.nested_types) | ||
| names.update(e.name for e in desc.enum_types) | ||
| names.update(dir(object())) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
What does this do?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It's including all the fields message fields, nested message and enum types, and boilerplate methods and attributes inherited from object. The important one is fields, since they weren't visible before, but since this is customizing __dir__ we need to explicitly add all the others back in too.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
🤖 I have created a release *beep* *boop* --- ## [1.20.0](v1.19.9...v1.20.0) (2022-02-07) ### Features * add custom __dir__ for messages and message classes ([#289](#289)) ([35e019e](35e019e)) ### Bug Fixes * workaround for buggy pytest ([#291](#291)) ([28aa3b2](28aa3b2)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
🤖 I have created a release *beep* *boop* --- ## [1.20.0](googleapis/proto-plus-python@v1.19.9...v1.20.0) (2022-02-07) ### Features * add custom __dir__ for messages and message classes ([#289](googleapis/proto-plus-python#289)) ([35e019e](googleapis/proto-plus-python@35e019e)) ### Bug Fixes * workaround for buggy pytest ([#291](googleapis/proto-plus-python#291)) ([28aa3b2](googleapis/proto-plus-python@28aa3b2)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.