Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyright Improvements #932

Merged
merged 28 commits into from
Jan 17, 2025
Merged

Pyright Improvements #932

merged 28 commits into from
Jan 17, 2025

Conversation

bpkroth
Copy link
Contributor

@bpkroth bpkroth commented Jan 16, 2025

Pull Request

Title

Pyright improvements


Description

Pyright is a type checker that ships with VSCode's Pylance by default.

It is billed as a faster, though less complete, version of mypy.

As such it gets a few things a little differently that mypy and alerts in VSCode.

This PR fixes those ("standard") alerts and removes the mypy extension from VSCode's default extensions for MLOS in favor of just using pyright (there's no sense in running both interactively). We do not enable pyright's "strict" mode.

Additionally, it enables pyright in pre-commit rules to ensure those fixes remain.

We leave the rest of the mypy checks as well since they are still useful.

A list of some of the types of fixes:

  • TypeDict initialization checks for Tunables
  • Check that json.loads() returns a dict and not a list (e.g.)
  • Replace ConcreteOptimizer TypeVar with a TypeAlias
  • Add BoundMethod protocol for checking self attribute
  • Ensure correct type inference in a number of places
  • Add ... to Protocol methods to make pyright aware of the lack of method body.
  • Fix a few type annotations

Type of Change

  • 🛠️ Bug fix
  • 🔄 Refactor

Testing

  • Additional CI checks as described above.

@bpkroth bpkroth requested a review from a team as a code owner January 16, 2025 22:46
@bpkroth bpkroth added the ready for review Ready for review label Jan 17, 2025
@bpkroth bpkroth merged commit e91546e into microsoft:main Jan 17, 2025
16 checks passed
@bpkroth bpkroth deleted the pyright branch January 17, 2025 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review Ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants