-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
isinstance(x, mock.Mock) is broken since Mock is aliased to Any #3224
Labels
stubs: false positive
Type checkers report false errors
Comments
Subclassing sounds to be the best solution to me, if it works. That also means we could add methods to it, which exist on the implementation. Cc @JelleZijlstra |
srittau
added
size-small
stubs: false positive
Type checkers report false errors
labels
Oct 11, 2019
Also |
srittau
added a commit
to srittau/typeshed
that referenced
this issue
Oct 13, 2019
Currently this is just an alias for Any like Mock and MagicMock. All of these classes should probably be sub-classing Any and add their own methods. See also python#3224.
srittau
added a commit
that referenced
this issue
Oct 14, 2019
* Add os.add_dll_directory() * Add memfd_create() and flags * Add type annotation to flags * Add stat_result.st_reparse_tag and flags * Add ncurses_version * Add Path.link_to() * Add Picker.reducer_override() * Add plistlib.UID * Add has_dualstack_ipv6() and create_server() * Add shlex.join() * Add SSL methods and fields * Add Python 3.8 statistics functions and classes * Remove obsolete sys.subversion * Add sys.unraisablehook * Add threading.excepthook * Add get_native_id() and Thread.native_id * Add Python 3.8 tkinter methods * Add CLOCK_UPTIME_RAW * Add SupportsIndex * Add typing.get_origin() and get_args() * Add unicodedata.is_normalized * Add unittest.mock.AsyncMock Currently this is just an alias for Any like Mock and MagicMock. All of these classes should probably be sub-classing Any and add their own methods. See also #3224. * Add unittest cleanup methods * Add IsolatedAsyncioTestCase * Add ElementTree.canonicalize() and C14NWriterTarget * cProfile.Profile can be used as a context manager * Add asyncio task name handling * mmap.flush() now always returns None * Add posonlyargcount to CodeType
I believe this is fixed by #3846 and others |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#3182 changed
mock.Mock
to be an alias toAny
, which resulted in mypy complaining aboutisinstance(x, mock.Mock)
, which I believe should be valid.We can fix this by reverting #3182 or potentially by making
Mock
a class with anAny
base class.Mock
is a class at runtime, so making it an alias toAny
(which is not a class) seems wrong to me.The text was updated successfully, but these errors were encountered: