Skip to content

Refactor/rename "private" wrappers to not lie about being private so type hinting and autocomplete work #50

Description

@negentropicdev

For example, this is the docstring for _FIFO:

Image

However this is in fact returned to user code via the Session.fifos property but cannot be imported and therefor type hinted properly because of the underscore. This is a pervasive pattern throughout nifpga making development slower using this library since most type hints become Any and intellisense/autocompletion is impossible. These "private" classes are in fact the public API of parts of the library and should be refactored as such.

Effort has been put into ensuring functional docstrings are throughout the code yet they remain out of reach to editors. Reading documentation is much slower than being able to get code completion in the editor.

Additionally, it should be possible to provide consistent public APIs so that the different internal types aren't exposed to users and there wouldn't need to be so much reliance on type unions:

Image

I'm happy to take a crack at this and submit a PR if this sounds good. It should be possible to accomplish without impact to user code but I'd like to discuss a few options and preferences since there are gaps in docstrings across related code. e.g. _FxpFifo has docstrings for methods but _DataConvertingFifo does not so one of my questions is would it be better to:

  • collapse to a single class with a flag for the type so it can internally differentiate behavior
  • utilize inheritance and docstring the super class method definitions
  • something else?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions