Skip to content

singledispatch and typing.Tuple[x] interaction #384

Closed
@Tinche

Description

@Tinche

Hello,

Python 3.5, but I'm using typing.py from this repo, master branch. (Trying to port a library.)

I realize this is not really the intended use of typing.

I'm not really sure if this is an issue in typing or singledispatch, but it used to work before. Here's a small test case. Note that typing.Tuple[int] is a subclass of typing.Tuple, and typing.Tuple is a subclass of typing.Sequence.

import typing
from functools import singledispatch

s = singledispatch(lambda: 'default')
s.register(typing.Sequence, lambda: 'sequence')
s.register(typing.Tuple, lambda: 'tuple')

print(s.dispatch(typing.Tuple[int])())

If you run it a number of times, the results are either 'tuple' or 'sequence', based on the ordering of an internal dict in singledispatch. This is a bug in singledispatch, right?

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