ChrisBuilds / terminaltexteffects

TerminalTextEffects (TTE) is a terminal visual effects engine, application, and Python library.
https://chrisbuilds.github.io/terminaltexteffects/
MIT License
2.6k stars 43 forks source link

Providing a way to use typed objects as arguments #5

Closed Navid-Means-Promise closed 4 months ago

Navid-Means-Promise commented 4 months ago

As we discussed about in this issue, in the current PR I provided a file named "argsdataclass.py" that contains two important classes ArgsDataClass and ArgField. Also I created a directory named "examples" that suppose to contain examples of using TTE in codes but temporarily it contains two files to demonestrate how to use typed args using ArgsDataClass

Navid-Means-Promise commented 4 months ago

Sorry for that you told me before about mypy. now the code do pass it in the last commit. About ArgField class I must say it is extended from python internal Field class defined in dataclass module and it meant to be assigned to a field . it's mentioned in pep 0557 Also there is a helper function named field in the same module that will create and return an instance of Field class. Mypy do accept assigning the result of field function to a field but not directly assigning new instance of Field class or any class extended from it. As there was a bug in mypy for dealing even with field function until Feb 2023 and due to my further research I convinced raising alerts about assigning in this case, is not correct; so I dealt the problem using # type: ignore[assignment] at the end of field definitions.

ChrisBuilds commented 4 months ago

Thanks. I'll poke around with the typing stuff and implement this functionality around the code base.