-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Ensure py.typed is present in all packages (BUILD-660) #27491
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
def git_ls_files(pattern: str) -> list[str]: | ||
return ( | ||
subprocess.run(["git", "ls-files", pattern], check=True, text=True, capture_output=True) | ||
.stdout.strip() | ||
.split("\n") | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When git ls-files
finds no matches, stdout.strip()
returns an empty string, which split('\n')
converts to ['']
. To handle this case correctly, the code should return an empty list instead:
.split('\n') if stdout.strip() else []
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
8e0d228
to
65ff6fc
Compare
Deploy preview for dagster-docs ready! Preview available at https://dagster-docs-crvhf1x5x-elementl.vercel.app Direct link to changed pages: |
65ff6fc
to
6ae2e37
Compare
357f918
to
79a0cdb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
Summary & Motivation
py.typed
to all Python packages (anything with a setup.py that can be installed into an environment)py.typed
, and all published packages include it in theirMANIFEST.in
There are a few reasons for this:
py.typed
is not present. In particular, pyright/pylance will not use annotations from a non-py.typed
package unlessuseLibraryCodeForTypes
is enabled (and we don't control whether our users enable this). Not all of our packages are 100% typed, but they at least do not provide wrong type information (which some packages, especially those using fancy metaprogramming, do), which means it is safe to expose the type information they do have.py.typed
to avoid some strange behavior aroundmake quick_pyright
, which runs in our configured pre-push hooks. If only some files in a non-py.typed
package are touched in a diff, it can lead to odd import resolution errors. This occurs because the files not touched by the diff are both not passed directly topyright
for inspection, and also unavailable from the venv environmentpyright
uses due to lackingpy.typed
. The result is the occasional seemingly random error whenmake quick_pyright
is run-- this PR fixes that.How I Tested These Changes
See notes on above test.
Changelog
All published dagster libraries now include a
py.typed
file, which means their type annotations will be used by static analyzers. Previously a few libraries were missing this file.