nutti / fake-bpy-module

Fake Blender Python API module collection for the code completion.
MIT License
1.37k stars 97 forks source link

Use most recent Python Syntax in .pyi files #161

Closed JonathanPlasse closed 2 weeks ago

JonathanPlasse commented 9 months ago

In .pyi files, the most recent syntax of python can be used, as it is only used for static analysis.

Therefore, these changes can be made:

I could work on this, to familiarize myself with the codebase.

nutti commented 4 months ago

@JonathanPlasse

Yes, go ahead. Currently, we use Python 3.9 for the generation which does not support these syntax. You many need to change Python version as well. https://github.com/nutti/fake-bpy-module/blob/97f5da91c52f9cab440e16c60cdd1eed5b68329e/.github/workflows/fake-bpy-module-ci.yml#L69

JonathanPlasse commented 4 months ago

Ok, I will start working on it.

nutti commented 4 months ago

@JonathanPlasse

207 is merged now.

Will you also tackle the remain (PEP695) as wall?

JonathanPlasse commented 4 months ago

I will.

Road-hog123 commented 4 months ago

Can I suggest PEP 673's Self type as a related change?

Presently ID.evaluated_get() returns ID, but if this were changed to Self then I believe Object.evaluated_get() would correctly return Object instead of ID.

Unfortunately the documentation just lists the return type as ID, so I don't know if there's anything for the generation code to detect to make this change automatically.

JonathanPlasse commented 4 months ago

To avoid regression, we should use the plugin flake-pyi available in Ruff to check we use the modern syntax in the generated code.

nutti commented 4 months ago

@JonathanPlasse

Should this issue be still opened? I think some features have already merged.

JonathanPlasse commented 4 months ago

Can I suggest PEP 673's Self type as a related change?

Presently ID.evaluated_get() returns ID, but if this were changed to Self then I believe Object.evaluated_get() would correctly return Object instead of ID.

Unfortunately the documentation just lists the return type as ID, so I don't know if there's anything for the generation code to detect to make this change automatically.

This one would be interesting.

To avoid regression, we should use the plugin flake-pyi available in Ruff to check we use the modern syntax in the generated code.

This one would be cool to have.

Is it a problem for you if the issue remains open? Should we open a specific issue for each remaining point instead?

nutti commented 4 months ago

No, I just would like to know the current status and the future plan. We welcome your contribution.

JonathanPlasse commented 4 months ago

I updated the initial comment.

nutti commented 3 months ago

@JonathanPlasse

Ruff linter is now merged to the master branch. You can tackle the remaining task now.

nutti commented 2 months ago

@JonathanPlasse

Can I suggest PEP 673's Self type as a related change?

Presently ID.evaluated_get() returns ID, but if this were changed to Self then I believe Object.evaluated_get() would correctly return Object instead of ID.

Unfortunately the documentation just lists the return type as ID, so I don't know if there's anything for the generation code to detect to make this change automatically.

By solving this feature, I solved below item.

nutti commented 2 months ago

@JonathanPlasse

I think below item seems to have already been resolved by the ruff linter introduced.

How do you think about it?

JonathanPlasse commented 2 months ago

Does it check that the generated code passes the rules of flake8-pyi?

nutti commented 2 weeks ago

Use type Parameter Syntax

This is introduced by https://github.com/nutti/fake-bpy-module/commit/d08d5c4100d3c896b08a03db70cf529766f5104c.

nutti commented 2 weeks ago

Close this issue because all tasks are done.