armoha / euddraft

System for pluginizing eudplib codes.
Other
29 stars 4 forks source link

[eudplib] Type checking with mypy #89

Open armoha opened 1 year ago

armoha commented 1 year ago

Current status

Migrate from Cython to mypyc

Replace metaclass

If a class definition uses an unsupported metaclass, mypyc compiles the class into a regular Python class. (source)

  • [ ] core.eudstruct.eudstruct.EUDStruct
  • [ ] core.eudstruct.structarr._EUDStruct_Metaclass
  • [ ] core.eudstruct.structarr.EUDStructArray

    Replace runtime-defined dynamic class

  • [ ] core.eudfunc.eudfptr.PtrDataClass
  • [x] core.eudstruct.structarr.EUDStructArray
  • [ ] core.eudstruct.varray._EUDVArray
  • [ ] core.eudstruct.varray._EUDVArrayData
  • [ ] eudlib.epdoffsetmap.OffsetMap
  • [ ] eudlib.eudqueue._EUDQueue
  • [ ] eudlib.eudqueue._EUDDeque
  • [ ] eudlib.eudstack._EUDStack
  • [x] eudlib.unitgroup._CPLoop
  • [x] eudlib.unitgroup.Dying

    eudplib does not use class decorators except dataclasses.dataclass

    Similar to metaclasses, most class decorators aren’t supported with native classes, as they are usually too dynamic. These class decorators can be used with native classes, however:

    • mypy_extensions.trait (for defining trait types)
    • mypy_extensions.mypyc_attr (see above)
    • dataclasses.dataclass
  • eudlib.utilf.unlimiterflag._UnlimiterBool
  • eudlib.objpool._GlobalObjPool

    How to integerate mypyc

    https://mypyc.readthedocs.io/en/stable/getting_started.html https://ichard26.github.io/blog/2022/05/compiling-black-with-mypyc-part-1/ mypyc is a transcompiler converting typed Python code into fast C extensions. Being built on top of the mypy type checker, it leverages standard type annotations (Unlike Cython).

armoha commented 9 months ago

+Lint and format with Ruff