Skip to content

Error while checking an edx-platform django model file #19215

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

Closed
feanil opened this issue Jun 3, 2025 · 1 comment
Closed

Error while checking an edx-platform django model file #19215

feanil opened this issue Jun 3, 2025 · 1 comment
Labels

Comments

@feanil
Copy link

feanil commented Jun 3, 2025

Crash Report

When running mypy to check types the checker crashes with the error below.

Traceback

❯ mypy /home/feanil/src/openedx/edx-platform/openedx/core/djangoapps/discussions/models.py --show-traceback
/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/fs/__init__.py:4: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  __import__("pkg_resources").declare_namespace(__name__)
/home/feanil/src/openedx/edx-platform/openedx/core/djangoapps/discussions/models.py:334: 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: 1.17.0+dev.1f339c035aaafd618ee3f78b638d0929b2f3e470
Traceback (most recent call last):
  File "/home/feanil/.virtualenvs/edx-platform/bin/mypy", line 8, in <module>
    sys.exit(console_entry())
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/__main__.py", line 15, in console_entry
    main()
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/main.py", line 127, in main
    res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/main.py", line 211, in run_build
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/build.py", line 191, in build
    result = _build(
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/build.py", line 267, in _build
    graph = dispatch(sources, manager, stdout)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/build.py", line 2939, in dispatch
    process_graph(graph, manager)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/build.py", line 3337, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/build.py", line 3438, in process_stale_scc
    graph[id].type_check_first_pass()
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/build.py", line 2311, in type_check_first_pass
    self.type_checker().check_first_pass()
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checker.py", line 471, in check_first_pass
    self.accept(d)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checker.py", line 578, in accept
    stmt.accept(self)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/nodes.py", line 1216, in accept
    return visitor.visit_class_def(self)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checker.py", line 2542, in visit_class_def
    self.accept(defn.defs)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checker.py", line 578, in accept
    stmt.accept(self)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/nodes.py", line 1297, in accept
    return visitor.visit_block(self)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checker.py", line 3031, in visit_block
    self.accept(s)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checker.py", line 578, in accept
    stmt.accept(self)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/nodes.py", line 1384, in accept
    return visitor.visit_assignment_stmt(self)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checker.py", line 3080, in visit_assignment_stmt
    self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None, s.new_syntax)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checker.py", line 3292, in check_assignment
    rvalue_type = self.expr_checker.accept(rvalue, type_context=type_context)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checkexpr.py", line 5931, in accept
    typ = node.accept(self)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/nodes.py", line 2006, in accept
    return visitor.visit_call_expr(self)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checkexpr.py", line 488, in visit_call_expr
    return self.visit_call_expr_inner(e, allow_none_return=allow_none_return)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checkexpr.py", line 622, in visit_call_expr_inner
    ret_type = self.check_call_expr_with_callee_type(
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checkexpr.py", line 1478, in check_call_expr_with_callee_type
    ret_type, callee_type = self.check_call(
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checkexpr.py", line 1580, in check_call
    return self.check_callable_call(
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checkexpr.py", line 1793, in check_callable_call
    arg_types = self.infer_arg_types_in_context(callee, args, arg_kinds, formal_to_actual)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checkexpr.py", line 1967, in infer_arg_types_in_context
    res[ai] = self.accept(args[ai], arg_type)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checkexpr.py", line 5931, in accept
    typ = node.accept(self)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/nodes.py", line 2006, in accept
    return visitor.visit_call_expr(self)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checkexpr.py", line 488, in visit_call_expr
    return self.visit_call_expr_inner(e, allow_none_return=allow_none_return)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checkexpr.py", line 578, in visit_call_expr_inner
    self.accept(e.callee, type_context, always_allow_any=True, is_callee=True)
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checkexpr.py", line 5931, in accept
    typ = node.accept(self)
          ^^^^^^^^^^^^^^^^^
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/nodes.py", line 1930, in accept
    return visitor.visit_member_expr(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checkexpr.py", line 3303, in visit_member_expr
    result = self.analyze_ordinary_member_access(e, is_lvalue)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checkexpr.py", line 3333, in analyze_ordinary_member_access
    member_type = analyze_member_access(
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checkmember.py", line 226, in analyze_member_access
    result = _analyze_member_access(name, typ, mx, override_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checkmember.py", line 243, in _analyze_member_access
    return analyze_instance_member_access(name, typ, mx, override_info)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checkmember.py", line 383, in analyze_instance_member_access
    return analyze_member_var_access(name, typ, info, mx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy/checkmember.py", line 608, in analyze_member_var_access
    result = hook(
             ^^^^^
  File "/home/feanil/.virtualenvs/edx-platform/lib/python3.11/site-packages/mypy_django_plugin/transformers/functional.py", line 23, in resolve_str_promise_attribute
    return analyze_member_access(
           ^^^^^^^^^^^^^^^^^^^^^^
TypeError: analyze_member_access() got an unexpected keyword argument 'msg'
/home/feanil/src/openedx/edx-platform/openedx/core/djangoapps/discussions/models.py:334: : note: use --pdb to drop into pdb

To Reproduce

(Write what you did to reproduce the crash. Full source code is
appreciated. We also very much appreciate it if you try to narrow the
source down to a small stand-alone example.)

git clone git@github.com:openedx/edx-platform.git
cd edx-platform
git checkout 67c0c255eadd7d4db0718b9c6b01b4b5eb3e49dd
python3 -m venv .venv
source .venv/bin/activate
make requirements
mypy /home/feanil/src/openedx/edx-platform/openedx/core/djangoapps/discussions/models.py --show-traceback

Your Environment

  • Mypy version used: 1.17.0+dev.1f339c035aaafd618ee3f78b638d0929b2f3e470
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files): In the repo at the relevant hash above.
  • Python version used: 3.11
  • Operating system and version: Ubuntu 24.04
@feanil feanil added the crash label Jun 3, 2025
@feanil feanil changed the title Error while checking an edx-platform djnago model file Error while checking an edx-platform django model file Jun 3, 2025
@sterliakov
Copy link
Collaborator

sterliakov commented Jun 3, 2025

This is a compatibility issue in Django plugin, they probably haven't upgraded yet. Note that traceback shows a call originating from mypy_djago_plugin with argument name/count mismatch. It should be reported to https://github.com/typeddjango/django-stubs instead, and was already reported there:

typeddjango/django-stubs#2696

@sterliakov sterliakov closed this as not planned Won't fix, can't repro, duplicate, stale Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants