Skip to content

AttributeError: 'FuncDef' object has no attribute 'is_trivial_self' #381

Description

Python code:

from typing import Any

from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet


class UserView(ModelViewSet):
    """Create, List, Update user model. Available for SuperAdmin only."""

    def list(
        self,
        *args: Any,
        **kwargs: Any,
    ) -> Response:
        return Response({"a": 1})

Returns an error when checking AttributeError: 'FuncDef' object has no attribute 'is_trivial_self'

Diagnostic Data

  • Python version 3.12.10
uv pip list
Package                       Version
----------------------------- -----------------
amqp                          5.3.1
argcomplete                   3.6.2
asgiref                       3.8.1
async-timeout                 4.0.3
attrs                         25.3.0
autobahn                      24.4.2
automat                       25.4.16
billiard                      4.2.1
celery                        5.4.0
certifi                       2023.11.17
cffi                          1.17.1
channels                      4.0.0
channels-redis                4.1.0
charset-normalizer            3.4.2
click                         8.1.7
click-didyoumean              0.3.1
click-plugins                 1.1.1
click-repl                    0.3.0
colorama                      0.4.6
commitizen                    4.8.2
constantly                    23.10.4
coreapi                       2.3.3
coreschema                    0.0.4
cron-descriptor               1.4.3
croniter                      3.0.3
cryptography                  45.0.3
daphne                        4.0.0
decli                         0.6.3
django                        4.2.7
django-aesfield               4.0.0
django-celery-beat            2.6.0
django-cors-headers           4.3.1
django-filter                 24.3
django-stubs                  1.9.0
django-stubs-ext              5.2.0
django-timezone-field         7.1
djangorestframework           3.14.0
djangorestframework-simplejwt 5.3.0
djangorestframework-stubs     1.4.0
drf-extra-fields              3.7.0
drf-yasg                      1.21.7
et-xmlfile                    2.0.0
filetype                      1.2.0
flake8                        7.2.0
grpcio                        1.59.3
grpcio-tools                  1.59.3
gunicorn                      21.2.0
hyperlink                     21.0.0
idna                          3.10
incremental                   24.7.2
inflection                    0.5.1
iniconfig                     2.1.0
itypes                        1.2.0
jinja2                        3.1.6
kombu                         5.5.4
loguru                        0.7.2
m2secret-py3                  1.3
markupsafe                    3.0.2
mccabe                        0.7.0
msgpack                       1.1.0
mypy                          1.16.0
mypy-extensions               1.1.0
numpy                         1.26.2
openpyxl                      3.1.5
orjson                        3.9.14
packaging                     25.0
pandas                        2.1.3
pandas-stubs                  2.3.0.250703
pathspec                      0.12.1
pluggy                        1.6.0
prompt-toolkit                3.0.51
protobuf                      4.25.1
psycopg2-binary               2.9.9
pyasn1                        0.6.1
pyasn1-modules                0.4.2
pycodestyle                   2.13.0
pycparser                     2.22
pyflakes                      3.3.2
pygments                      2.19.1
pyjwt                         2.10.1
pyopenssl                     25.1.0
pytest                        8.4.0
python-crontab                3.2.0
python-dateutil               2.9.0.post0
python-dotenv                 1.0.0
pytz                          2025.2
pyyaml                        6.0.2
questionary                   2.1.0
redis                         5.0.1
requests                      2.31.0
ruff                          0.11.12
service-identity              24.2.0
setuptools                    80.9.0
six                           1.17.0
sqlparse                      0.5.3
termcolor                     2.5.0
toml                          0.10.2
tomlkit                       0.13.3
twisted                       24.11.0
txaio                         23.1.1
types-grpcio                  1.0.0.20250603
types-protobuf                4.25.0.20240417
types-pytz                    2025.2.0.20250516
types-pyyaml                  6.0.12.20250516
types-requests                2.32.0.20250602
typing-extensions             4.14.0
tzdata                        2025.2
uritemplate                   4.2.0
urllib3                       2.4.0
vine                          5.1.0
wcwidth                       0.2.13
wemake-python-styleguide      1.1.0
xlsxwriter                    3.1.9
zope-interface                7.2

Behaviour

Expected Behavior

Actual Behavior

Reproduction Steps:

Logs:

2025-09-03 07:50:36.389 [info] [Trace - 7:50:36 AM] Received notification 'textDocument/publishDiagnostics'.
2025-09-03 07:50:36.924 [info] [Trace - 7:50:36 AM] Sending notification 'textDocument/didChange'.
2025-09-03 07:50:37.063 [info] [Trace - 7:50:37 AM] Sending notification 'textDocument/didChange'.
2025-09-03 07:50:37.213 [info] [Trace - 7:50:37 AM] Sending notification 'textDocument/didChange'.
2025-09-03 07:50:37.560 [info] [Trace - 7:50:37 AM] Sending notification 'textDocument/didSave'.
2025-09-03 07:50:37.564 [info] [Trace - 7:50:37 AM] Received notification 'window/logMessage'.
2025-09-03 07:50:37.565 [info] /home/name/projects/oss-core/osscore/.venv/bin/python3 -m mypy --no-color-output --no-error-summary --show-absolute-path --show-column-numbers --show-error-codes --no-pretty --config-file=./pyproject.toml --show-error-end /home/name/projects/oss-core/osscore/t.py
2025-09-03 07:50:37.565 [info] [Trace - 7:50:37 AM] Received notification 'window/logMessage'.
2025-09-03 07:50:37.566 [info] CWD Server: /home/name/projects/oss-core/osscore
2025-09-03 07:50:39.195 [info] [Trace - 7:50:39 AM] Received notification 'window/logMessage'.
2025-09-03 07:50:39.195 [info] /home/name/projects/oss-core/osscore/.venv/lib/python3.12/site-packages/drf_yasg/__init__.py:2: 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.
  from pkg_resources import DistributionNotFound, get_distribution
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/name/.vscode/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/mypy/__main__.py", line 37, in <module>
    console_entry()
  File "/home/name/.vscode/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/mypy/__main__.py", line 15, in console_entry
    main()
  File "/home/name/.vscode/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/mypy/main.py", line 119, in main
    res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/name/.vscode/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/mypy/main.py", line 203, in run_build
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/name/.vscode/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/mypy/build.py", line 191, in build
    result = _build(
             ^^^^^^^
  File "/home/name/.vscode/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/mypy/build.py", line 267, in _build
    graph = dispatch(sources, manager, stdout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/name/.vscode/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/mypy/build.py", line 2937, in dispatch
    process_graph(graph, manager)
  File "/home/name/.vscode/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/mypy/build.py", line 3328, in process_graph
    process_fresh_modules(graph, prev_scc, manager)
  File "/home/name/.vscode/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/mypy/build.py", line 3406, in process_fresh_modules
    graph[id].load_tree()
  File "/home/name/.vscode/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/mypy/build.py", line 2096, in load_tree
    self.tree = MypyFile.deserialize(data)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/name/.vscode/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/mypy/nodes.py", line 389, in deserialize
    tree.names = SymbolTable.deserialize(data["names"])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/name/.vscode/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/mypy/nodes.py", line 4039, in deserialize
    st[key] = SymbolTableNode.deserialize(value)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/name/.vscode/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/mypy/nodes.py", line 3980, in deserialize
    node = SymbolNode.deserialize(data["node"])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/name/.vscode/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/mypy/nodes.py", line 250, in deserialize
    return method(data)
           ^^^^^^^^^^^^
  File "/home/name/.vscode/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/mypy/nodes.py", line 3401, in deserialize
    names = SymbolTable.deserialize(data["names"])
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/name/.vscode/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/mypy/nodes.py", line 4039, in deserialize
    st[key] = SymbolTableNode.deserialize(value)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/name/.vscode/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/mypy/nodes.py", line 3980, in deserialize
    node = SymbolNode.deserialize(data["node"])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/name/.vscode/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/mypy/nodes.py", line 250, in deserialize
    return method(data)
           ^^^^^^^^^^^^
  File "/home/name/.vscode/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/mypy/nodes.py", line 853, in deserialize
    set_flags(ret, data["flags"])
  File "/home/name/.vscode/extensions/ms-python.mypy-type-checker-2025.2.0/bundled/libs/mypy/nodes.py", line 4099, in set_flags
    setattr(node, name, True)
AttributeError: 'FuncDef' object has no attribute 'is_trivial_self'

2025-09-03 07:50:39.195 [info] [Trace - 7:50:39 AM] Received notification 'window/logMessage'.
2025-09-03 07:50:39.195 [info] file:///home/vvoronov/projects/oss-core/osscore/t.py :

2025-09-03 07:50:39.195 [info] [Trace - 7:50:39 AM] Received notification 'textDocument/publishDiagnostics'.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions