-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
mypy warning: tests/__init__.py:34: error: Cannot assign to a method #494
Comments
* Add subcommands to the individual codeformat test One often wants to run the very fast codeformatting tests without running any of the unit tests. Add a commands to allow this behavior with "./runtests.sh [--black|--pytype|--mypy|--flake8]". One often wants the `black` formatting tool to automatically fix formatting violations without requiring explicit manual call. Use "./runtests.sh --black-fix" Add mypy static checking tool to monai Run the complete mypy static checking tool during evaluations of code format style checks. Related to #476 subtask for enable mypy Expand the documentation for runtest.sh script. Provide more expressive documentation for `-h` The dryrun request to print the commands used for static and format checking without actually running the commands. * Temporarily add branch needed to trigger CI of this codebase. * Suppress mypy warnings about incompatible superclass signature Related to #495 * Suppress mypy error: Cannot assign to a method Related to #494 * Mypy potential type mismatch resolved with assertion. * Mypy type ambiguity resolved.
@benjamin-gorman Could you try to address this warning? |
Work arounds# preferable (see context)
setattr(unittest.case._AssertWarnsContext, "__enter__", _enter_pr_4800)
# but has flake8-bugbear error
# B010 Do not call setattr with a constant attribute value, it is not any safer than normal property access. # ignore the specific error
unittest.case._AssertWarnsContext.__enter__ = _enter_pr_4800 # type: ignore[assignment] Context
Progression of _enter_pr_4800AlternativelyThere is the typing.Protocol fix but that would require a |
the workaround is well documented Lines 32 to 36 in bbc2da5
closing this issue |
Describe the bug
mypy static checker provides warning:
tests/__init__.py:34: error: Cannot assign to a method
To Reproduce
Steps to reproduce the behavior:
tests/__init__.py
MYPYPATH=$(pwd)/monai mypy $(pwd)
Expected behavior
No warnings produced.
The text was updated successfully, but these errors were encountered: