-
Notifications
You must be signed in to change notification settings - Fork 161
fix error on definition for implicit abstract classes #1318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Back to you with some comments
Seems that 6f6634d will fail... extends_abc() returns true even when the class inherits an ABC only indirectly, because the flag is propagated through base metadata. Child(Base) now satisfies failures:
---- test::abstract_methods::test_abstract_async_iterator stdout ----
DEBUG Running with 3 threads (5 MiB stack size)
DEBUG Running epoch 1 of run 0
DEBUG Committing transaction
ERROR Abstract methods for async generators should use `def`, not `async def` [bad-function-definition]
--> pyrefly/lib/test/abstract_methods.rs:240:15
|
240 | async def foo(self) -> AsyncIterator[int]: # E: Abstract methods for async generators should use `def`, not `async def`
| ^^^
|
Error: Expectations failed for in-memory pyrefly/lib/test/abstract_methods.rs: expected 2 errors, but got 1
---- test::abstract_methods::test_abstract_property stdout ----
DEBUG Running with 3 threads (5 MiB stack size)
DEBUG Running epoch 1 of run 0
DEBUG Committing transaction
ERROR Cannot instantiate `Child` because the following members are abstract: `processor` [bad-instantiation]
--> pyrefly/lib/test/abstract_methods.rs:225:10
|
225 | x = Child() # E: Cannot instantiate `Child`
| ^^
|
Error: Expectations failed for in-memory pyrefly/lib/test/abstract_methods.rs: expected 2 errors, but got 1
---- test::abstract_methods::test_inherited_abstract_method stdout ----
DEBUG Running with 3 threads (5 MiB stack size)
DEBUG Running epoch 1 of run 0
DEBUG Committing transaction
ERROR Cannot instantiate `Child` because the following members are abstract: `method` [bad-instantiation]
--> pyrefly/lib/test/abstract_methods.rs:102:14
|
102 | child = Child() # E: Cannot instantiate `Child`
| ^^
|
Error: Expectations failed for in-memory pyrefly/lib/test/abstract_methods.rs: expected 2 errors, but got 1
---- test::abstract_methods::test_partial_implementation stdout ----
DEBUG Running with 3 threads (5 MiB stack size)
DEBUG Running epoch 1 of run 0
DEBUG Committing transaction
ERROR Cannot instantiate `Partial` because the following members are abstract: `method2` [bad-instantiation]
--> pyrefly/lib/test/abstract_methods.rs:144:12
|
144 | p = Partial() # E: Cannot instantiate `Partial`
| ^^
|
Error: Expectations failed for in-memory pyrefly/lib/test/abstract_methods.rs: expected 2 errors, but got 1
failures:
test::abstract_methods::test_abstract_async_iterator
test::abstract_methods::test_abstract_property
test::abstract_methods::test_inherited_abstract_method
test::abstract_methods::test_partial_implementation |
Let me import and investigate |
@yangdanny97 has imported this pull request. If you are a Meta employee, you can view this in D85072634. |
You're right, extends_abc will return true if it's transitive, we'd need a similar check for a class directly extending ABC. I'll see if I can patch this |
I believe I've managed to patch it internally. Instead of storing the metaclass as Option, I made an enum that encodes its origin. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review automatically exported from Phabricator review in Meta.
@yangdanny97 merged this pull request in 5e9b54b. |
fix #1200