-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: fix TypeError when running test.pebble_cli #1245
Conversation
Without this fix, running this raises the following: TypeError: catching classes that do not inherit from BaseException is not allowed
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.
Given that it’s a script and typing issue get fixed…
I don’t quite understand the original type hint though.
How do you reproduce the error? I've started pebble with: PEBBLE=/tmp/pebble go run ./cmd/pebble run and running $ PEBBLE=/tmp/pebble /tmp/opsenv/bin/python3 test/pebble_cli.py system-info
SystemInfo(version='v1.10.0-dev')
$ /tmp/opsenv/bin/python3 --version
Python 3.12.3 Are you using a different Python? Or should I run it differently? |
@tonyandrewmeyer You have to run an
|
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.
I have the feeling I maybe introduced this - when I was adding hints to all the test files the older version of pyright seemed to want the exceptions like this, although it's clearly invalid.
I also don't know of any way to say "catch this exception and I know that it will be this concrete type". So I think the first ignore is required.
The second ignore could be removed if you have a e = typing.cast(pebble.ExecError[str], e)
but I think having the ignore there is fine in this context.
It feels like, just as with Python typing in many places, having generic exception classes doesn't work very well.
Without this fix, running this raises the following: ``` TypeError: catching classes that do not inherit from BaseException is not allowed ``` Not sure how to silence pyright without the type: ignores. I guess we haven't used this script in a while. :-)
Without this fix, running this raises the following:
Not sure how to silence pyright without the type: ignores.
I guess we haven't used this script in a while. :-)