Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-108158

Use monkeytype to add stable type annotations to stratis-cli

Linking RHIVOS CVEs to...Migration: Automation ...Sync from "Extern...XMLWordPrintable

    • Icon: Epic Epic
    • Resolution: Unresolved
    • Icon: Undefined Undefined
    • None
    • rhel-10.0
    • stratis-cli
    • None
    • Use monkeytype to add stable type annotations to stratis-cli
    • Hide

       * When stratis-cli code and Python version are unchanged, annotations of the stratis-cli files that are annotated are stable. The action of annotating and then formatting should be idempotent.
       * Newly introduced code in files that are among those already annotated should receive new, correct annotations before the changes are merged.

      • The majority of files in the code base in the src directory should be annotated.
      Show
       * When stratis-cli code and Python version are unchanged, annotations of the stratis-cli files that are annotated are stable. The action of annotating and then formatting should be idempotent.  * Newly introduced code in files that are among those already annotated should receive new, correct annotations before the changes are merged. The majority of files in the code base in the src directory should be annotated.
    • 100% To Do, 0% In Progress, 0% Done
    • False
    • Hide

      None

      Show
      None
    • Unspecified
    • Unspecified
    • Unspecified

       * As a developer, I would like to write slightly less buggy Python code slightly faster. My ability to do this is, of course, somewhat reduced by Python's type system, where type-checking is actually done at run time. Since a long time ago Python has had gradual typing. We have not previously made use of it, because it never seemed to make anything better. A while back, I began using pyright to lint our Python code. It turned out to be quite useful and also to rely rather heavily on a kind of type inference. Type annotations in the Python source code that it was linting assisted it to do a better job of linting and thereby detecting bugs.
       * Being the developer I am I have hoped to find an annotation tool or other durable way to add annotations to source code so that it was sustainable with ongoing development and not a single pass action that then grew stale. Recently a colleague introduced me to monkeytype which is a dynamic type inteference engine which also annotates. While it has its defects, monkeytype works really well on stratis-cli due to stratis-cli's simple-as-possible structure and nearly 100% code coverage. Using monkeytype and some formatters it is possible to make the use of monkeytype a repeatable thing.

      There is an upstream issue about this: https://github.com/stratis-storage/project/issues/89 .

              stratis-team stratis-team
              amulhern@redhat.com the Mulhern
              stratis-team stratis-team
              Filip Suba Filip Suba
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated: