fake-bpy-module
fake-bpy-module copied to clipboard
Use most recent Python Syntax in .pyi files
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:
- [ ] Remove all quotes (future annotation)
- [x] Use
|
instead ofOptional
andUnion
(PEP 604) (#207) - [ ] Use
type
Parameter Syntax (PEP 695) - [x] Use
list
,dict
, … instead oftyping.List
,typing.Dict
, … (PEP 585)- [x] builtin (#207)
- [x]
collections.abc
(#223)
- [x] Use
Self
(PEP 673) - [ ] Add Ruff and enable linter rules to avoid regression we encountered (c.f. #222, #224, #296)
I could work on this, to familiarize myself with the codebase.
@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
Ok, I will start working on it.
@JonathanPlasse
#207 is merged now. Will you also tackle the remain (PEP695) as wall?
I will.
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.
To avoid regression, we should use the plugin flake-pyi
available in Ruff to check we use the modern syntax in the generated code.
@JonathanPlasse
Should this issue be still opened? I think some features have already merged.
Can I suggest PEP 673's
Self
type as a related change?Presently
ID.evaluated_get()
returnsID
, but if this were changed toSelf
then I believeObject.evaluated_get()
would correctly returnObject
instead ofID
.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?
No, I just would like to know the current status and the future plan. We welcome your contribution.
I updated the initial comment.
@JonathanPlasse
Ruff linter is now merged to the master branch. You can tackle the remaining task now.
@JonathanPlasse
Can I suggest PEP 673's
Self
type as a related change?Presently
ID.evaluated_get()
returnsID
, but if this were changed toSelf
then I believeObject.evaluated_get()
would correctly returnObject
instead ofID
.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.
- Use Self (PEP 673)
@JonathanPlasse
I think below item seems to have already been resolved by the ruff linter introduced.
- Add Ruff and enable linter rules to avoid regression we encountered
How do you think about it?
Does it check that the generated code passes the rules of flake8-pyi?