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

Raise TypeError in easy_install.CommandSpec.from_param #4548

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

Avasam
Copy link
Contributor

@Avasam Avasam commented Aug 8, 2024

Summary of changes

Follow-up to #4505 (comment)
As mentioned in that comment, let's include this PR in a major update since, although an edge case, isn't backwards compatible.

Changed the type of error raised by setuptools.command.easy_install.CommandSpec.from_param on unsupported argument from AttributeError to TypeError.

Pull Request Checklist

@Avasam Avasam changed the title Runtime changes for typeshed merge Raise TypeError in easy_install.CommandSpec.from_param Aug 8, 2024
Comment on lines 1335 to 1344
def test_from_param_raises_expected_error(self) -> None:
"""
from_param should raise its own TypeError when the argument's type is unsupported
"""
try:
ei.CommandSpec.from_param(object()) # type: ignore[arg-type] # We want a type error here
except Exception as error:
assert type(error) is TypeError, error
assert (
str(error) == "Argument has an unsupported type <class 'object'>"
), error
else:
raise AssertionError(
"from_param did not raise any error for argument of unsupported type"
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/pypa/setuptools/actions/runs/10307637126/job/28533318670?pr=4548#step:5:74

setuptools/tests/test_easy_install.py (85.7%): Missing lines 1347

Darn, coverage check includes the test themselves. Is there a better way to do a "expect to fail with specific error" test ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it can be a bit overwhelming.

Is there a better way to do a "expect to fail with specific error" test ?

Have you tried pytest.raises?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what I found as well. Looks a lot cleaner, thanks.

@Avasam Avasam marked this pull request as ready for review August 8, 2024 18:36
@Avasam Avasam force-pushed the from_param-TypeError branch 2 times, most recently from 9674f40 to 190462c Compare August 9, 2024 19:30
Copy link
Contributor

@abravalheri abravalheri left a comment

Choose a reason for hiding this comment

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

WE can merge this once we are preparing a new major release.

Thank you!

@Avasam
Copy link
Contributor Author

Avasam commented Aug 20, 2024

We can merge this once we are preparing a new major release.

Didn't make it to 73 ^^"

@abravalheri
Copy link
Contributor

Sorry, I was not cutting that release :(

Let's just wait two weeks and merge it anyway.

@abravalheri
Copy link
Contributor

It seems that there might be a release soon with changes in distutils... So it might be a good idea to merge this now.

@abravalheri abravalheri merged commit 5f8215d into pypa:main Aug 27, 2024
21 checks passed
@Avasam Avasam deleted the from_param-TypeError branch August 27, 2024 19:28
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.

2 participants