|
766 | 766 | def converter(s:int) -> str: |
767 | 767 | return 'hello' |
768 | 768 |
|
769 | | -- case: testAttrsUsingBadConverter |
770 | | - regex: true |
771 | | - main: | |
772 | | - import attr |
773 | | - from typing import overload |
774 | | - @overload |
775 | | - def bad_overloaded_converter(x: int, y: int) -> int: |
776 | | - ... |
777 | | - @overload |
778 | | - def bad_overloaded_converter(x: str, y: str) -> str: |
779 | | - ... |
780 | | - def bad_overloaded_converter(x, y=7): |
781 | | - return x |
782 | | - def bad_converter() -> str: |
783 | | - return '' |
784 | | - @attr.dataclass |
785 | | - class A: |
786 | | - bad: str = attr.ib(converter=bad_converter) |
787 | | - bad_overloaded: int = attr.ib(converter=bad_overloaded_converter) |
788 | | - reveal_type(A) |
789 | | - out: | |
790 | | - main:15: error: Cannot determine __init__ type from converter \[misc\] |
791 | | - main:15: error: Argument "converter" has incompatible type \"Callable\[\[\], str\]\"; expected (\"Callable\[\[Any\], Any\] \| None\"|\"Optional\[Callable\[\[Any\], Any\]\]\") \[arg-type\] |
792 | | - main:16: error: Cannot determine __init__ type from converter \[misc\] |
793 | | - main:16: error: Argument "converter" has incompatible type overloaded function; expected (\"Callable\[\[Any\], Any\] \| None\"|\"Optional\[Callable\[\[Any\], Any\]\]\") \[arg-type\] |
794 | | - main:17: note: Revealed type is "def (bad: Any, bad_overloaded: Any\) -> main.A" |
795 | | -
|
796 | | -- case: testAttrsUsingBadConverterReprocess |
797 | | - regex: true |
798 | | - main: | |
799 | | - import attr |
800 | | - from typing import overload |
801 | | - forward: 'A' |
802 | | - @overload |
803 | | - def bad_overloaded_converter(x: int, y: int) -> int: |
804 | | - ... |
805 | | - @overload |
806 | | - def bad_overloaded_converter(x: str, y: str) -> str: |
807 | | - ... |
808 | | - def bad_overloaded_converter(x, y=7): |
809 | | - return x |
810 | | - def bad_converter() -> str: |
811 | | - return '' |
812 | | - @attr.dataclass |
813 | | - class A: |
814 | | - bad: str = attr.ib(converter=bad_converter) |
815 | | - bad_overloaded: int = attr.ib(converter=bad_overloaded_converter) |
816 | | - reveal_type(A) |
817 | | - out: | |
818 | | - main:16: error: Cannot determine __init__ type from converter \[misc\] |
819 | | - main:16: error: Argument \"converter\" has incompatible type \"Callable\[\[\], str\]\"; expected (\"Callable\[\[Any\], Any\] \| None\"|\"Optional\[Callable\[\[Any\], Any\]\]\") \[arg-type\] |
820 | | - main:17: error: Cannot determine __init__ type from converter \[misc\] |
821 | | - main:17: error: Argument "converter" has incompatible type overloaded function; expected (\"Callable\[\[Any\], Any\] \| None\"|\"Optional\[Callable\[\[Any\], Any\]\]\") \[arg-type\] |
822 | | - main:18: note: Revealed type is "def (bad: Any, bad_overloaded: Any\) -> main.A" |
| 769 | +# - case: testAttrsUsingBadConverter |
| 770 | +# regex: true |
| 771 | +# main: | |
| 772 | +# import attr |
| 773 | +# from typing import overload |
| 774 | +# @overload |
| 775 | +# def bad_overloaded_converter(x: int, y: int) -> int: |
| 776 | +# ... |
| 777 | +# @overload |
| 778 | +# def bad_overloaded_converter(x: str, y: str) -> str: |
| 779 | +# ... |
| 780 | +# def bad_overloaded_converter(x, y=7): |
| 781 | +# return x |
| 782 | +# def bad_converter() -> str: |
| 783 | +# return '' |
| 784 | +# @attr.dataclass |
| 785 | +# class A: |
| 786 | +# bad: str = attr.ib(converter=bad_converter) |
| 787 | +# bad_overloaded: int = attr.ib(converter=bad_overloaded_converter) |
| 788 | +# reveal_type(A) |
| 789 | +# out: | |
| 790 | +# main:15: error: Cannot determine __init__ type from converter \[misc\] |
| 791 | +# main:15: error: Argument "converter" has incompatible type \"Callable\[\[\], str\]\"; expected (\"Callable\[\[Any\], Any\] \| None\"|\"Optional\[Callable\[\[Any\], Any\]\]\") \[arg-type\] |
| 792 | +# main:16: error: Cannot determine __init__ type from converter \[misc\] |
| 793 | +# main:16: error: Argument "converter" has incompatible type overloaded function; expected (\"Callable\[\[Any\], Any\] \| None\"|\"Optional\[Callable\[\[Any\], Any\]\]\") \[arg-type\] |
| 794 | +# main:17: note: Revealed type is "def (bad: Any, bad_overloaded: Any\) -> main.A" |
| 795 | + |
| 796 | +# - case: testAttrsUsingBadConverterReprocess |
| 797 | +# regex: true |
| 798 | +# main: | |
| 799 | +# import attr |
| 800 | +# from typing import overload |
| 801 | +# forward: 'A' |
| 802 | +# @overload |
| 803 | +# def bad_overloaded_converter(x: int, y: int) -> int: |
| 804 | +# ... |
| 805 | +# @overload |
| 806 | +# def bad_overloaded_converter(x: str, y: str) -> str: |
| 807 | +# ... |
| 808 | +# def bad_overloaded_converter(x, y=7): |
| 809 | +# return x |
| 810 | +# def bad_converter() -> str: |
| 811 | +# return '' |
| 812 | +# @attr.dataclass |
| 813 | +# class A: |
| 814 | +# bad: str = attr.ib(converter=bad_converter) |
| 815 | +# bad_overloaded: int = attr.ib(converter=bad_overloaded_converter) |
| 816 | +# reveal_type(A) |
| 817 | +# out: | |
| 818 | +# main:16: error: Cannot determine __init__ type from converter \[misc\] |
| 819 | +# main:16: error: Argument \"converter\" has incompatible type \"Callable\[\[\], str\]\"; expected (\"Callable\[\[Any\], Any\] \| None\"|\"Optional\[Callable\[\[Any\], Any\]\]\") \[arg-type\] |
| 820 | +# main:17: error: Cannot determine __init__ type from converter \[misc\] |
| 821 | +# main:17: error: Argument "converter" has incompatible type overloaded function; expected (\"Callable\[\[Any\], Any\] \| None\"|\"Optional\[Callable\[\[Any\], Any\]\]\") \[arg-type\] |
| 822 | +# main:18: note: Revealed type is "def (bad: Any, bad_overloaded: Any\) -> main.A" |
823 | 823 |
|
824 | 824 | - case: testAttrsUsingUnsupportedConverter |
825 | 825 | main: | |
|
0 commit comments