euddraft icon indicating copy to clipboard operation
euddraft copied to clipboard

[eudplib] Type checking with mypy

Open armoha opened this issue 2 years ago • 1 comments

Current status

  • [x] core.allocator
  • [ ] core.calcf
  • [ ] core.eudfunc
  • [x] core.eudobj
  • [ ] core.eudstruct
  • [x] core.mapdata
  • [x] core.rawtrigger
  • [x] core.variable
  • [ ] core.curpl, core.inplacecw
  • [x] core.inlines
  • [x] ctrlstru
  • [ ] epscript
  • [ ] eudlib.locf
  • [ ] eudlib.mathf
  • [ ] eudlib.memiof
  • [ ] eudlib.qgcf
  • [ ] eudlib.stringf
  • [ ] eudlib.utilf
  • [ ] eudlib.wireframe
  • [ ] eudlib.epdoffsetmap
  • [ ] eudlib.eudarray
  • [ ] eudlib.eudgrp
  • [ ] eudlib.eudqueue
  • [ ] eudlib.eudstack
  • [ ] eudlib.objpool
  • [ ] eudlib.playerv
  • [ ] eudlib.s
  • [ ] eudlib.sparseset
  • [ ] eudlib.unitgroup
  • [x] localize
  • [x] maprw
  • [x] trigger
  • [x] trigtrg
  • [x] utils

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 avatar Oct 21 '22 07:10 armoha

+Lint and format with Ruff

armoha avatar Dec 10 '23 16:12 armoha