Author thepabloaguilar
Recipients thepabloaguilar
Date 2021-07-13.03:34:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Hey, I'm not sure if this is really a bug but I'd like to show to prevent some undesired behavior!

I'm working in the `match` support for returns ( library when I saw a behavior similar to the described in `Constant Value Patterns` section on PEP-622 (

A very small and reproducible example:
from typing import Any, ClassVar, Optional

class Maybe:
    empty: ClassVar['Maybe']
    _instance: Optional['Maybe'] = None

    def __new__(cls, *args: Any, **kwargs: Any) -> 'Maybe':
        if cls._instance is None:
            cls._instance = object.__new__(cls)
        return cls._instance

Maybe.empty = Maybe()

if __name__ == '__main__':
    my_maybe = Maybe()
    match my_maybe:
        case Maybe.empty:
            print('FIRST CASE')
        case _:
            print('DEFAULT CASE')

The output here is `FIRST CASE`, but if I delete `__new__` method the output is `DEFAULT CASE`.

Is that the correct behavior?

Python version: 3.10.0a7
Date User Action Args
2021-07-13 03:34:48thepabloaguilarsetrecipients: + thepabloaguilar
2021-07-13 03:34:48thepabloaguilarsetmessageid: <>
2021-07-13 03:34:48thepabloaguilarlinkissue44617 messages
2021-07-13 03:34:47thepabloaguilarcreate