Skip to content

Using the latest discord.py and mypy with namespace_packages enabled together causes a crush #12725

Closed
@tasuren

Description

@tasuren

Crash Report
When I run mypy with namespace_packages set to True in a project that uses a library called discord.py (latest on github), it crashes.

Traceback

/Users/tasuren/.pyenv/versions/3.10.3/lib/python3.10/site-packages/./discord/ext/commands/help.py:631: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.950
Traceback (most recent call last):
  File "mypy/checkexpr.py", line 3981, in accept
  File "mypy/nodes.py", line 1753, in accept
  File "mypy/checkexpr.py", line 288, in visit_call_expr
  File "mypy/checkexpr.py", line 371, in visit_call_expr_inner
  File "mypy/checkexpr.py", line 880, in check_call_expr_with_callee_type
  File "mypy/checkexpr.py", line 944, in check_call
  File "mypy/checkexpr.py", line 1621, in check_overload_call
  File "mypy/checkexpr.py", line 1763, in infer_overload_return_type
  File "mypy/checkexpr.py", line 940, in check_call
  File "mypy/checkexpr.py", line 1027, in check_callable_call
  File "mypy/checkexpr.py", line 1269, in infer_function_type_arguments
  File "mypy/checkexpr.py", line 1324, in infer_function_type_arguments_pass2
  File "mypy/infer.py", line 47, in infer_function_type_arguments
  File "mypy/constraints.py", line 72, in infer_constraints_for_callable
  File "mypy/constraints.py", line 108, in infer_constraints
  File "mypy/constraints.py", line 181, in _infer_constraints
  File "mypy/types.py", line 1576, in accept
  File "mypy/constraints.py", line 610, in visit_callable_type
  File "mypy/constraints.py", line 108, in infer_constraints
  File "mypy/constraints.py", line 181, in _infer_constraints
  File "mypy/types.py", line 1127, in accept
  File "mypy/constraints.py", line 551, in visit_instance
  File "mypy/constraints.py", line 731, in infer_against_any
  File "mypy/constraints.py", line 108, in infer_constraints
  File "mypy/constraints.py", line 181, in _infer_constraints
  File "mypy/types.py", line 1365, in accept
  File "mypy/constraints.py", line 410, in visit_parameters
RuntimeError: Parameters cannot be constrained to
/Users/tasuren/.pyenv/versions/3.10.3/lib/python3.10/site-packages/./discord/ext/commands/help.py:631: : note: use --pdb to drop into pdb

The location where the INTERNAL ERROR occurred is here.

To Reproduce
Run pip3 install -U git+https://github.com/Rapptz/discord.py to install latest discord.py from github.
Write the following in test.py.

import discord

Run mypy test.py --namespace-packages --show-traceback.

Your Environment

  • Mypy version used: 0.950
  • Mypy command-line flags: --namespace-packages
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.10.3
  • Operating system and version: macOS Monterey 12.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions