Skip to content
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

Erg pystd fixes #515

Merged
merged 2 commits into from
Jul 8, 2024
Merged

Erg pystd fixes #515

merged 2 commits into from
Jul 8, 2024

Conversation

lion24
Copy link

@lion24 lion24 commented Jul 8, 2024

Relates to #213

The following PR fixes a typo in abc.d.er and add missing subclasshook api.

Changes proposed in this PR:

  • feat(erg): add subclasshook method in abc.d.er
  • fix(erg_compiler): fix typo in abc.d.er otherwise linting an interface that use subclasshook method will fail

@mtshiba

Lionel H added 2 commits July 8, 2024 11:07
s/abstruct/abstract/g

Because abstruct does not exists in Python ;)

Signed-off-by: Lionel H <lionel.hubaut@dekimo.com>
Add __subclasshook__ magic method which is used to implement the logic
that validates a class correctly conform to an interface.

Signed-off-by: Lionel H <lionel.hubaut@dekimo.com>
@mtshiba mtshiba merged commit d57f0f6 into erg-lang:main Jul 8, 2024
21 checks passed
@mtshiba
Copy link
Member

mtshiba commented Jul 8, 2024

Thank you!

@lion24
Copy link
Author

lion24 commented Jul 8, 2024

Hi @mtshiba

Thanks for the approval 😊

That's a pitty that those files needs to be manually written.
Maybe you already start to explore this, but I'm currently doing researchs to check if it's not possible to use the Python AST to transpiled modules file directly into erg code.
I already have something that work for a basic class containing some methods. I still didn't look on the reflection way for the module discovery.

But that would be great to not have to wrote those file manually and let the transpiler automatically generate them 😄

BTW this is a great project.

Cheers,
Lionel.

@mtshiba
Copy link
Member

mtshiba commented Jul 9, 2024

Hi, thanks for your contribution to the Erg project and your constructive comments!

Actually, I'm trying out the idea too, but automatic generation of type definition files with pylyzer is still experimental. The advantage of being able to inspect modules that are not typed manually is great, but the quality difference is still big.
Not only that, Erg has its own advanced type system, which has a lot to offer that type inference can't provide, so there's no way around it other than generating it manually.

The current best practice is to generate type definition files using pylyzer and then manually edit them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants