Skip to content

Add type stubs for P4 and P4API#11

Open
yangskyboxlabs wants to merge 1 commit intoperforce:masterfrom
yangskyboxlabs:types
Open

Add type stubs for P4 and P4API#11
yangskyboxlabs wants to merge 1 commit intoperforce:masterfrom
yangskyboxlabs:types

Conversation

@yangskyboxlabs
Copy link

This adds fairly comprehensive type annotations for P4API, and partially complete annotations for P4.

P4.P4 is difficult to annotate more precisely as the run()-based functions have very loose argument semantics, and their outputs can very wildly based on input and internal state.

Note that this addition does not currently support packaging. Python does not currently define a mechanism for indicating that a shared native library located outside of a package folder has type information.

To actually ship this, AFAICT, p4python needs either:

  • To be reorganized such that at least P4API is moved into a package so it can have stub annotation.
  • Publish a separate p4python-stubs package for stubs.

This adds fairly comprehensive type annotations for P4API, and partially
complete annotations for P4.

P4.P4 is difficult to annotate more precisely as the run()-based
functions have very loose argument semantics, and their outputs can very
wildly based on input and internal state.

Note that this addition does not currently support packaging.  Python
does not currently define a mechanism for indicating that a shared
native library located outside of a package folder has type information.
@yangskyboxlabs
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant