Skip to content

Allow ... in some non-stub-file function bodies (protocol, abstract, etc) #2159

@QEDady

Description

@QEDady

Describe the Bug

It seems that Pyrefly is permissive when using ... in functions or methods and totally reject pass e.g. in the following:

from typing import Protocol

class A(Protocol):
  def __foo__(self) -> int:
    pass
  def __bar__(self) -> int:
    ...

def foo() -> int:
    pass

def bar() -> int:
    ...

Pyrefly is ok with pass in both locations but rejects ... in both locations.

I think writing pass should be ok if used with protocols, abstract methods, .pyi, etc. On the other hand, I also think using ... should be an error outside of these abstract contexts. Other type checkers do that e.g. both ty and mypy would be ok with the protocol methods above but would flag the two functions after.

Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEALqcROgOZ0Q3G6UN0AFag1wBjXFAA66aaKio4cOgEEAFENwjxUAJSJpdOphhg6AfTNhcuC6rgwoYHXQC0APk7oG%2B9IcPEFOAMjE3MzbFRKW3tHZ3dPb2DDQhTpaWNTK1xVOI9WRN8-AMU0rFCIyhzXPK8fPzoUwhAAGhAyShMoUkIRGigKAGJBUg6wLro0LDx8OnF0SDYAV0pUBghcdEJpIYBlGBg6AAsGBmI4RAB6C-bO7t42C5h0C8wxOAu5heXV9ee6K0odFQADdUNBUNhYLMNl8VmsNnRcMR4eg4Ft0GQGIcNi5gTBKHBfnQALx0SQgADMhAAjAAmcnSEAAX1aqFEazxADFoDAKJMcAQSOQmUA

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

Labels

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions