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

Add check for abstract static/class method #15249

Closed

Conversation

madt2709
Copy link
Contributor

Fixes #14939.

Adds an extra check to check_callable_call in checkexpr.py.

I'm not entirely sure if this is the right place in the code to add this but seemed most appropriate to me.

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

mitmproxy (https://github.com/mitmproxy/mitmproxy)
+ mitmproxy/coretypes/serializable.py:57: error: Cannot call static/class abstract method: "from_state"  [abstract]
+ mitmproxy/coretypes/multidict.py:50: error: Cannot call static/class abstract method: "_reduce_values"  [abstract]
+ mitmproxy/coretypes/multidict.py:58: error: Cannot call static/class abstract method: "_kconv"  [abstract]
+ mitmproxy/coretypes/multidict.py:60: error: Cannot call static/class abstract method: "_kconv"  [abstract]
+ mitmproxy/coretypes/multidict.py:66: error: Cannot call static/class abstract method: "_kconv"  [abstract]
+ mitmproxy/coretypes/multidict.py:72: error: Cannot call static/class abstract method: "_kconv"  [abstract]
+ mitmproxy/coretypes/multidict.py:84: error: Cannot call static/class abstract method: "_kconv"  [abstract]
+ mitmproxy/coretypes/multidict.py:85: error: Cannot call static/class abstract method: "_kconv"  [abstract]
+ mitmproxy/coretypes/multidict.py:91: error: Cannot call static/class abstract method: "_kconv"  [abstract]
+ mitmproxy/coretypes/multidict.py:95: error: Cannot call static/class abstract method: "_kconv"  [abstract]

schema_salad (https://github.com/common-workflow-language/schema_salad)
+ schema_salad/python_codegen_support.py: note: In member "load" of class "_RecordLoader":
+ schema_salad/python_codegen_support.py:499:16: error: Cannot call static/class abstract method: "fromDoc"  [abstract]
+ schema_salad/metaschema.py: note: In member "load" of class "_RecordLoader":
+ schema_salad/metaschema.py:502:16: error: Cannot call static/class abstract method: "fromDoc"  [abstract]

cloud-init (https://github.com/canonical/cloud-init)
+ cloudinit/net/activators.py:63: error: Cannot call static/class abstract method: "bring_up_interface"  [abstract]
+ cloudinit/net/activators.py:245: error: Cannot call static/class abstract method: "available"  [abstract]

pyjwt (https://github.com/jpadilla/pyjwt)
+ jwt/api_jwk.py:60: error: Cannot call static/class abstract method: "from_jwk"  [abstract]

cwltool (https://github.com/common-workflow-language/cwltool)
+ cwltool/job.py: note: In member "create_file_and_add_volume" of class "ContainerCommandLineJob":
+ cwltool/job.py:686:13: error: Cannot call static/class abstract method: "append_volume"  [abstract]
+ tests/test_environment.py: note: In function "test_basic":
+ tests/test_environment.py:208:14: error: Cannot call static/class abstract method: "checks"  [abstract]
+ tests/test_environment.py: note: In function "test_preserve_single":
+ tests/test_environment.py:231:14: error: Cannot call static/class abstract method: "checks"  [abstract]
+ tests/test_environment.py: note: In function "test_preserve_all":
+ tests/test_environment.py:255:14: error: Cannot call static/class abstract method: "checks"  [abstract]

kornia (https://github.com/kornia/kornia)
+ kornia/augmentation/container/ops.py:107: error: Cannot call static/class abstract method: "transform"  [abstract]
+ kornia/augmentation/container/ops.py:125: error: Cannot call static/class abstract method: "inverse"  [abstract]

anyio (https://github.com/agronholm/anyio)
+ src/anyio/abc/_eventloop.py:108: error: Cannot call static/class abstract method: "current_effective_deadline"  [abstract]
+ src/anyio/abc/_eventloop.py:109: error: Cannot call static/class abstract method: "checkpoint"  [abstract]
+ src/anyio/abc/_eventloop.py:120: error: Cannot call static/class abstract method: "create_cancel_scope"  [abstract]
+ src/anyio/abc/_eventloop.py:121: error: Cannot call static/class abstract method: "sleep"  [abstract]
+ src/anyio/_core/_eventloop.py:66: error: Cannot call static/class abstract method: "run"  [abstract]
+ src/anyio/_core/_eventloop.py:79: error: Cannot call static/class abstract method: "sleep"  [abstract]
+ src/anyio/_core/_eventloop.py:115: error: Cannot call static/class abstract method: "current_time"  [abstract]
+ src/anyio/_core/_eventloop.py:125: error: Cannot call static/class abstract method: "cancelled_exception_class"  [abstract]
+ src/anyio/lowlevel.py:33: error: Cannot call static/class abstract method: "checkpoint"  [abstract]
+ src/anyio/lowlevel.py:70: error: Cannot call static/class abstract method: "current_token"  [abstract]
+ src/anyio/_core/_testing.py:59: error: Cannot call static/class abstract method: "get_current_task"  [abstract]
+ src/anyio/_core/_testing.py:69: error: Cannot call static/class abstract method: "get_running_tasks"  [abstract]
+ src/anyio/_core/_testing.py:74: error: Cannot call static/class abstract method: "wait_all_tasks_blocked"  [abstract]
+ src/anyio/_core/_tasks.py:29: error: Cannot call static/class abstract method: "create_cancel_scope"  [abstract]
+ src/anyio/_core/_tasks.py:113: error: Cannot call static/class abstract method: "current_time"  [abstract]
+ src/anyio/_core/_tasks.py:115: error: Cannot call static/class abstract method: "create_cancel_scope"  [abstract]
+ src/anyio/_core/_tasks.py:132: error: Cannot call static/class abstract method: "current_time"  [abstract]
+ src/anyio/_core/_tasks.py:134: error: Cannot call static/class abstract method: "create_cancel_scope"  [abstract]
+ src/anyio/_core/_tasks.py:148: error: Cannot call static/class abstract method: "current_effective_deadline"  [abstract]
+ src/anyio/_core/_tasks.py:158: error: Cannot call static/class abstract method: "create_task_group"  [abstract]
+ src/anyio/_core/_signals.py:25: error: Cannot call static/class abstract method: "open_signal_receiver"  [abstract]
+ src/anyio/_core/_synchronization.py:79: error: Cannot call static/class abstract method: "create_event"  [abstract]
+ src/anyio/_core/_synchronization.py:376: error: Cannot call static/class abstract method: "create_capacity_limiter"  [abstract]
+ src/anyio/from_thread.py:130: error: Cannot call static/class abstract method: "create_blocking_portal"  [abstract]
+ src/anyio/to_thread.py:33: error: Cannot call static/class abstract method: "run_sync_in_worker_thread"  [abstract]
+ src/anyio/to_thread.py:46: error: Cannot call static/class abstract method: "current_default_thread_limiter"  [abstract]
+ src/anyio/_core/_sockets.py:173: error: Cannot call static/class abstract method: "connect_tcp"  [abstract]
+ src/anyio/_core/_sockets.py:264: error: Cannot call static/class abstract method: "connect_unix"  [abstract]
+ src/anyio/_core/_sockets.py:324: error: Cannot call static/class abstract method: "create_tcp_listener"  [abstract]
+ src/anyio/_core/_sockets.py:358: error: Cannot call static/class abstract method: "create_unix_listener"  [abstract]
+ src/anyio/_core/_sockets.py:404: error: Cannot call static/class abstract method: "create_udp_socket"  [abstract]
+ src/anyio/_core/_sockets.py:454: error: Cannot call static/class abstract method: "create_udp_socket"  [abstract]
+ src/anyio/_core/_sockets.py:561: error: Cannot call static/class abstract method: "getaddrinfo"  [abstract]
+ src/anyio/_core/_sockets.py:581: error: Cannot call static/class abstract method: "getnameinfo"  [abstract]
+ src/anyio/_core/_sockets.py:601: error: Cannot call static/class abstract method: "wait_socket_readable"  [abstract]
+ src/anyio/_core/_sockets.py:621: error: Cannot call static/class abstract method: "wait_socket_writable"  [abstract]
+ src/anyio/pytest_plugin.py:45: error: Cannot call static/class abstract method: "create_test_runner"  [abstract]
+ src/anyio/to_process.py:99: error: Cannot call static/class abstract method: "setup_process_pool_exit_at_shutdown"  [abstract]

ignite (https://github.com/pytorch/ignite)
+ ignite/handlers/param_scheduler.py:146: error: Cannot call static/class abstract method: "simulate_values"  [abstract]

aiortc (https://github.com/aiortc/aiortc)
+ src/aiortc/codecs/g711.py:28: error: Cannot call static/class abstract method: "_convert"  [abstract]
+ src/aiortc/codecs/g711.py:71: error: Cannot call static/class abstract method: "_convert"  [abstract]

bokeh (https://github.com/bokeh/bokeh)
+ src/bokeh/colors/color.py: note: In member "lighten" of class "Color":
+ src/bokeh/colors/color.py:174:16: error: Cannot call static/class abstract method: "from_rgb"  [abstract]

ibis (https://github.com/ibis-project/ibis)
+ ibis/backends/tests/base.py:88: error: Cannot call static/class abstract method: "connect"  [abstract]
+ ibis/backends/tests/base.py:240: error: Cannot call static/class abstract method: "service_spec"  [abstract]

@madt2709 madt2709 changed the title Add check for abstract static method Add check for abstract static/class method May 16, 2023
@madt2709
Copy link
Contributor Author

madt2709 commented Jun 7, 2023

@JukkaL any chance you could review this please? (or assign it to the relevant person)

@madt2709 madt2709 closed this Jan 16, 2024
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.

no error when calling abstract staticmethod/classmethod
1 participant