Skip to content

Request for dataclass backport support in 3.6 (using 3.6.6). #5389

Closed
python/typeshed
#2354
@bbarker

Description

@bbarker
  • Are you reporting a bug, or opening a feature request?

This is a bug for 3.6, supposedly works in 3.7. So, I'm requesting a backport of dataclass functionality for 3.6 if not too difficult.

Our initial use case looks like this, with a simple dataclass definition, and can be compared to the even simpler Point example in #3937, where we get error: Too many arguments for the constructor.

@dataclass(frozen=True)
class AuthorList:
    """Represents author names."""

    """Raw author field string."""
    raw: str = field(default_factory=str)

    def __str__(self) -> str:
        return self.raw

And a simple dataclass use:

        # TODO type ignore: possibly mypy #3937
        fields['authors'] = AuthorList(fields['authors'])  # type: ignore
  • What are the versions of mypy and Python you are using?

3.6.6 and 0.620

Do you see the same issue after installing mypy from Git master?

I have not tried.

  • What are the mypy flags you are using? (For example --strict-optional)
[mypy]

#
# Covered by --strict, with some turned off:
#
disallow_untyped_defs=True
check_untyped_defs=True
# currently an issue with sql alchemy
disallow_subclassing_any=false
# Need to experiment/think about this one:
disallow_any_decorated=false
warn_redundant_casts=True
warn_return_any=True
warn_unused_ignores=True
# this seems to be at least somewhat non-functioning:
warn_unused_configs=True
#may be worth reconsidering this one:
no_implicit_optional=True
strict_optional=True

#
# Other: 
#
ignore_missing_imports=True

[browse.*]
disallow_untyped_calls=True

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions