Skip to content

run: exchange manual mock of linecache.checkcache for unittest.mock.patch - #4429

Draft
behrmann wants to merge 1 commit into
systemd:mainfrom
behrmann:tycompat
Draft

run: exchange manual mock of linecache.checkcache for unittest.mock.patch#4429
behrmann wants to merge 1 commit into
systemd:mainfrom
behrmann:tycompat

Conversation

@behrmann

Copy link
Copy Markdown
Contributor

This is the successor to #4168 from which all things but one have been fixed.

The last remaining error ty is showing is

Object of type `(filename=None) -> None` is not assignable to attribute `checkcache` of type `def checkcache(filename: str | None = None) -> None`

which is a problem with ty's handling of shadowing being more conservative than other typecheckers.

Since what we want to do here is basically a mock, patching linecache.checkcache to a function that won't evict out cache entries, let's use a proper mock instead.

…atch

The last remaining error ty is showing is

    Object of type `(filename=None) -> None` is not assignable to attribute `checkcache` of type `def checkcache(filename: str | None = None) -> None`

which is a problem with ty's handling of shadowing being more conservative than
other typecheckers.

Since what we want to do here is basically a mock, patching
linecache.checkcache to a function that won't evict out cache entries, let's
use a proper mock instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant