Skip to content

cleanup: fix typing in command/build.py #249

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

Merged
merged 1 commit into from
Jul 26, 2024

Conversation

shubhbapna
Copy link
Collaborator

part of #226

fixes

src/fromager/commands/build.py:19: error: Function is missing a return type annotation  [no-untyped-def]
src/fromager/commands/build.py:54: error: Function is missing a return type annotation  [no-untyped-def]
src/fromager/commands/build.py:110: error: Argument 3 to "BuildEnvironment" has incompatible type "None"; expected "Iterable[Requirement]"  [arg-type]
src/fromager/commands/build.py:134: error: Argument "dist_version" to "run_post_build_hooks" has incompatible type "Version"; expected "str"  [arg-type]
src/fromager/commands/build.py:136: error: Argument "wheel_filename" to "run_post_build_hooks" has incompatible type "Path | None"; expected "Path"  [arg-type]
src/fromager/commands/build.py:139: error: Incompatible return value type (got "Path | None", expected "Path")  [return-value]

@shubhbapna shubhbapna requested review from tiran and dhellmann July 25, 2024 16:41
@@ -111,7 +111,7 @@ def build_wheel(
wheels = list(ctx.wheels_build.glob("*.whl"))
if wheels:
return wheels[0]
return None
raise FileNotFoundError(f"Could not locate the built wheels for {req.name}")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dhellmann from what I noticed wherever this function is called, the caller already expects a non null return value. Do you think if we raise an error instead of returning null it would be fine? Or would you rather make this change later?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do that separately so we can focus on test coverage for it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay then I will fix the type errors from this separately

@@ -111,7 +111,7 @@ def build_wheel(
wheels = list(ctx.wheels_build.glob("*.whl"))
if wheels:
return wheels[0]
return None
raise FileNotFoundError(f"Could not locate the built wheels for {req.name}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The signature of the exception class is a bit obscure. It takes an errno number, error string, and file or target name:

Suggested change
raise FileNotFoundError(f"Could not locate the built wheels for {req.name}")
raise FileNotFoundError(errno.ENOENT, "Could not locate the built wheels for", req.name)
>>> import errno
>>> from packaging.requirements import Requirement
>>> req = Requirement("egg==0.1")
>>> raise FileNotFoundError(errno.ENOENT, "Could not locate the built wheels for", req.name)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] Could not locate the built wheels for: 'egg'

Copy link
Collaborator

@tiran tiran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the exception call

@shubhbapna
Copy link
Collaborator Author

Please change the exception call

Will be adding the exception call in a separate PR. Have noted this down

@shubhbapna shubhbapna force-pushed the typing-command-build branch from 53a1d71 to 56c042b Compare July 26, 2024 13:07
@shubhbapna shubhbapna force-pushed the typing-command-build branch from 927747f to 7d147cb Compare July 26, 2024 13:10
@shubhbapna shubhbapna requested a review from tiran July 26, 2024 13:11
@mergify mergify bot merged commit 814f9d1 into python-wheel-build:main Jul 26, 2024
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants