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

Avoid error in FileInfo repr due to permissions being None #956

Merged
merged 1 commit into from
Jun 16, 2023

Conversation

benhoyt
Copy link
Collaborator

@benhoyt benhoyt commented Jun 15, 2023

FileInfo.__repr__ was raising a TypeError due to the expectation that permissions was never None, and the ":o" format string:

TypeError: unsupported format string passed to NoneType.__format__

At first I was surprised that Pyright didn't catch this, because clearly dict.get can return None, but we were defining a _FileKwargs TypedDict with a non-optional "permissions" field, so fix that too.

NOTE: this code will be removed and unnecessary if OP036 is done (using the real file system for the Harness's container filesystem), but might as well fix while the iron's hot.

Fixes #955

FileInfo.__repr__ was raising a TypeError due to the expectation that
permissions was never None, and the ":o" format string:

TypeError: unsupported format string passed to NoneType.__format__

At first I was surprised that Pyright didn't catch this, because
clearly dict.get can return None, but we were defining a _FileKwargs
TypedDict with a non-optional "permissions" field, so fix that too.

Fixes canonical#955
@benhoyt
Copy link
Collaborator Author

benhoyt commented Jun 16, 2023

Trivial fix in testing harness, going to merge without further review. I've tested against @yanksyoon's test case in #955, but I decided not to add this as an automated test seeing we're likely getting rid of that code anyway.

@benhoyt benhoyt merged commit 6fcda00 into canonical:main Jun 16, 2023
@benhoyt benhoyt deleted the fix-fileinfo-repr branch June 16, 2023 04: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.

NoneType.__format__ on pebble.FileInfo
1 participant