Skip to content

"Sequence[Collection[str]]" has no attribute "append" #13948

@hvignolo87

Description

@hvignolo87

Bug Report

When appending a dictionary to a nested list inside another dictionary, the linter throws an error with the text:

"Sequence[Collection[str]]" has no attribute "append"

This is a screenshot from VSCode:

mypy-bug

This is a screenshot from the console output in the same file:

mypy-bug2

To Reproduce

from pprint import pprint

# The main dict
section = {
    "type": "section",
    # Nested list
    "fields": [
        {"type": "mrkdwn", "text": "*File:*"},
        {
            "type": "mrkdwn",
            "text": "*Broken links:*",
        },
        {"type": "mrkdwn", "text": "*Links*"},
        {"type": "mrkdwn", "text": "*Status Code*"},
    ],
}

for text in ['a', 'b', 'c']:
    # Here is where the linter throws the error, in section variable
    section["fields"].append({"type": "plain_text", "text": f"{text}", "emoji": False})

pprint(section)

Expected Behavior

No error should be thrown.

Actual Behavior

"Sequence[Collection[str]]" has no attribute "append"

Your Environment

  • Mypy version used: 0.982
  • Mypy command-line flags: --follow-imports=skip
  • Mypy configuration options from mypy.ini (and other config files):
[mypy]
ignore_missing_imports = True
  • Python version used: 3.10.7

More info about my system

I'm working in Ubuntu 22.04 on WSL2. More information about my system is below:

Output of lsb_release -a command:

Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy

The output of the uname -a command:

Kernel name: Linux 
Kernel release: 5.15.68.1-microsoft-standard-WSL2 
Kernel version: #1 SMP Mon Sep 19 19:14:52 UTC 2022
Machine: x86_64 
Processor: x86_64 
Hardware platform: x86_64 
OS: GNU/Linux

The output of the docker version command:

Client: Docker Engine - Community
 Cloud integration: v1.0.29
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.17.11
 Git commit:        100c701
 Built:             Mon Jun  6 23:03:17 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Desktop
 Engine:
  Version:          20.10.17
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.11
  Git commit:       a89b842
  Built:            Mon Jun  6 23:01:23 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.8
  GitCommit:        9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-join-v-unionUsing join vs. using unionstopic-type-contextType context / bidirectional inference

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions