File: test_special_cases.py

package info (click to toggle)
python-overrides 7.7.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 244 kB
  • sloc: python: 1,661; sh: 5; makefile: 2
file content (43 lines) | stat: -rw-r--r-- 961 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from abc import ABC, abstractmethod
from collections.abc import MutableMapping
from concurrent.futures import Future
from typing import Callable, Any

from overrides import override


class MyInterface(ABC):
    @abstractmethod
    def run(self) -> "Future[str]":
        pass


class MyInterface2(ABC):
    @abstractmethod
    def run(self, callback: Callable[[str], None]):
        pass


def test_future_is_fine():
    class FutureWorks(MyInterface):
        @override
        def run(self) -> "Future[str]":
            pass


def test_callable_is_fine():
    class CallableWorks(MyInterface2):
        @override
        def run(self, callback: Callable[[str], None]):
            pass


def test_overriding_untyped_from_other_package_is_fine():
    class Params(MutableMapping):
        DEFAULT = object()

        @override
        def pop(
            self, key: str, default: Any = DEFAULT, keep_as_dict: bool = False
        ) -> Any:
            pass