Skip to content

OrderedDict() needs type annotation but {} doesn't #4551

Closed
@kamahen

Description

@kamahen

The following error message is triggered when by adding -> Dict[Text, Any] to the type signature:

/tmp/pod.py:7: error: Need type annotation for 'result'

This is the contents of /tmp/pod.py:

import collections
from typing import Any, Dict, Text

class PlainOldData:

    def as_json_dict(self) -> Dict[Text, Any]:
        result = collections.OrderedDict()
        for k in self.__slots__:
            value = getattr(self, k)
            if value is not None:
                result[k] = value
        return result

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions