azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

Type checking updates for CI

Open kristapratico opened this issue 3 years ago • 0 comments

Resolves https://github.com/Azure/azure-sdk-for-python/issues/23351

More and more, we see that our customers expect our client libraries to 1) include type hints and, 2) that our type hints are correct. We have decided to put more emphasis on typing and type checking for the Python SDK and want to begin to enforce this through CI.

To summarize the changes in this PR:

  • Changes running type checking from an opt-in check to an opt-out check in CI. The expectation is that any new library includes type hints and is type checked regularly. This matches our workflow with pylint which is also opt-out.
  • Adds pyright check to CI (another type checker, like mypy. Used by pylance/VSCode)
  • In addition to running on the src code, updates type checkers to also run on a library's samples dir so we can fix typing issues our customers see
  • Adds verifytypes check (a feature of pyright) which reports type completeness for a library. We fail on this check only if the type completeness score reported in the PR is less than that reported from the latest release (i.e. type completeness worsens).
  • Adds granular "opt-out" lists for running type checkers. In the same spirit of gradual typing, this will allow developers to incrementally improve typing in the libraries and opt-in to checks when clean.
  • Updates the docs and removes outdated information about type hints.

Any libraries that previously opted-in to type checking via mypy continue to do so. Merging this PR should create no new failures, as we currently ignore packages for any of the new checks. During MQ, there is a team-wide work item to work on improving typing/type checking of libraries and this PR will enable developers to pull their libraries off the opt-out lists and work on improving our type completeness.

kristapratico avatar Oct 07 '22 21:10 kristapratico