-
Notifications
You must be signed in to change notification settings - Fork 126
docs: add Advanced: PyOTA Commands page & refactoring
#275
docs: add Advanced: PyOTA Commands page & refactoring
#275
Conversation
todofixthis
left a comment
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.
Looks good! Added a few questions/suggestions.
docs/commands.rst
Outdated
|
|
||
| :py:class:`BaseCommand` is also decorated with a :py:class:`CommandMeta` | ||
| metaclass, that helps to register each command automatically in the API classes' | ||
| command registry at runtime. |
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.
💭 We could probably deprecate and remove this functionality; I don't think anybody uses the command registries.
Short version is, I wanted to make it so that developers didn't have to add methods to the Iota/StrictIota/MultisigIota/etc. classes explicitly. Instead, the registry would automatically load commands in the specified packages and attach them magically.
In exchange for being clever (i.e., no real benefits 😅), this approach had a number of drawbacks:
- Very difficult to understand which commands a particular API class can use via static analysis.
- Difficult to document how users should invoke each command, what parameters to provide, etc.
- IDEs couldn't support jumping from a command invocation to the corresponding class (e.g.,
self.commands['getNodeInfo']vs.core.GetNodeInfoCommand).
In #30 I laid the groundwork for making command registries redundant.
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.
I removed command registries and modified command test cases. take a look on dbb4de7 .
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.
Awesome! I added some comments to that commit.
c29fafb to
6bea33f
Compare
6bea33f to
a39c527
Compare
Advanced: PyOTA Commands pageAdvanced: PyOTA Commands page & refactoring
a39c527 to
0f2aa3b
Compare
- Removed auto command discovery in API class, as it was only used in tests. - Modified test cases. - Removed custom __getattr__() from API class.
Explain the inner workings of an API command for advanced users/developers of the the library.
0f2aa3b to
be39875
Compare
todofixthis
left a comment
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.
Looks good!
Related issue #268
Changes
Remove
auto command discovery.api.getTrytes(..)for example). This feature turned out not to have real benefits, as a user would always call the API method, not the command directly (api.get_trytes(...)) and it also messes with the static analysis of the IDE (autocompletion, suggestion, type hints, etc...).Add
Advanced: PyOTA Commandspage to docs.Commandsare used within API methods.filters, add reference tofiltersdocumentation.The
Advancednature of the doc page points out that this part is intended for people who would like to know how PyOTA works under the hood (advanced users/developers of the lib).