Skip to content

Conversation

@tochilinak
Copy link
Member

Description

Added support for such protocols:

class SupportsCall(Protocol):
    def __call__(self, *args, **kwargs):
        ...


class HasF(Protocol):
    f: SupportsCall


class SupportsSpecificCall(Protocol):
    def __call__(self, *args, **kwargs) -> HasF:
        ...


class HasSpecificF(Protocol):
    f: SupportsSpecificCall

Example of class that supports HasF but not HasSpecificF:

class S:
    def f(self, x: Union[int, str]) -> collections.Counter:
        return collections.Counter([x])

Example of class that supports HasSpecificF:

class RImpl:
    def f(self) -> 'RImpl':
        return self

How to test

Automated tests

  • utbot-python-types/src/test/kotlin/org/utbot/python/newtyping/PythonSubtypeCheckerTest.kt:
    • testSupportsCall
    • testSupportsSpecificCall

Self-check list

Check off the item if the statement is true. Hint: [x] is a marked item.

Please do not delete the list or its items.

  • I've set the proper labels for my PR (at least, for category and component).
  • PR title and description are clear and intelligible.
  • I've added enough comments to my code, particularly in hard-to-understand areas.
  • The functionality I've repaired, changed or added is covered with automated tests.
  • Manual tests have been provided optionally.
  • The documentation for the functionality I've been working on is up-to-date.

@tochilinak tochilinak added ctg-enhancement New feature, improvement or change request lang-python Issue is related to python support labels Nov 14, 2023
@tochilinak tochilinak self-assigned this Nov 14, 2023
@tochilinak tochilinak merged commit 355647c into main Nov 15, 2023
@tochilinak tochilinak deleted the tochillinak/types_fix branch November 15, 2023 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ctg-enhancement New feature, improvement or change request lang-python Issue is related to python support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants