facebook / facebook/pyrefly

bug: generic ABC is mistakenly allowed to be instantiated by providing a type argument to the constructor

Open
#4,263 1 comment 0 reactions 1 assignee Claimed by @asukaminato0721 View on GitHub
typechecking
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

```python
from abc import ABC, abstractmethod

class EyBeeSea(ABC):
@abstractmethod
def method(self) -> None:
raise NotImplementedError

def test_concrete_abc() -> None:
shouldnt = EyBeeSea()
# as expected, cant instantiate abstract class

class GenericEyBeeSea[A](ABC):
@abstractmethod
def method(self) -> A:
raise NotImplementedError

def test_generic_abc_no_arg() -> None:
shouldnt: GenericEyBeeSea[int] = GenericEyBeeSea()
# as expected, cant instantiate abstract class
def test_generic_abc_with_arg() -> None:
shouldnt: GenericEyBeeSea[int] = GenericEyBeeSea[int]()
# unexpectedly, when you add the type argument to the constructor, this is allowed?
# i think the "abstractness" gets lost somewhere here
```

### Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEq2AxnRDcbpQC50CCAQgGEANA2xwulVEy40YXABa5MAHXRqmUVHDh0AoqX4wYAZRioAFAMEBKRGrqO6AAUYSpMuYuUOnmGGB0XkqYFnAwUGA2dAC0AHx0AHK46DD26E6ZdFIQ4Um4XACS7LBy6FwwmHqU1JRqav6BFRIA%2BkwpTJTyMC2MTBbR8fmp6ZlwSgCuUJjldAC8%2BobGZpY2vo4AxAy6MPjEMDKVokwYPBDoEqcQqBVi7tI8mtpw9eroTzp0AOIwqZQQTAMRlM5gA2rwALpWIR2dYuNySB7BHwZPwBILyEJhCJRWIJXijLKOHJ5ZJFEowMoVKo1TivRp0ZpcFoAc1%2BMH%2BTF6zBa6FwvUoLIGeOGaTh41wUxmXEQ33ZnKByzB5y4EPmcr%2BAMVINWcK22jou32h0wx1OrAuXCuNxgd0RMjoHxeWHRTNZ8oB3K5AHcIIoBULBglkiNxZNpuVZT9NYCljrQSq1QtoxytXGVgnylDonq6BNUnsDtSoKRRN6FL86KRJQxMJhGRXGaR9gxBRMqYzcA3be1LZQJjJOKJFLlWLpUFAoLhvZUAPy5iAN84Aa27dBUIARHi4qR0G7obK4uinEjocFoMHLHNtFa6IGEIDIXTAJcIXFoUAoWwACqRnyWzwwHACEdFJIBZCYpC4CAUkINQtjMG8uC4Yg4EQAB6dCnwCV9OBZdDfnQzBcCYOB0N7cDIJuGD0HQugwE4BgADdUGgRhYFA9BKKgmi6FwYhoJSOA4PQMhvHQGImI5OBeIWDcAGZCAARgAJg3NRQQ5Wo4AhNR8zYDhuEqGJMAgLoZAgKT1QAcggFk%2BS6ay1D5LgYi6ABHCYzOM5cYFIGJpCYeBdAWazvVQSh0Cc9AQAAXwfB5LJgAAxaAYAoNAsDwIgyDioA

### (Only applicable for extension issues) IDE Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.