Cottonwood-Technology / ValidX

Fast, powerful, and flexible validator with sane syntax.
BSD 2-Clause "Simplified" License
20 stars 4 forks source link

Inheritance stopped working in version 0.8.1 #23

Open Adman opened 1 month ago

Adman commented 1 month ago

Imagine the following snippet:

import validx

class StrToUpper(validx.Str):
    def __call__(self, value, __context=None):
        return super().__call__(value=value.upper(), __context=__context)

if __name__ == "__main__":
    print(StrToUpper()("test"))

When executed with version 0.8, string TEST is printed.

However, when executed with version 0.8.1, the following error occurs

Traceback (most recent call last):
  File "/home/user/sandbox/test.py", line 10, in <module>
    StrToUpper()("test")
  File "/home/user/sandbox/test.py", line 6, in __call__
    return super().__call__(value=value.upper(), __context=__context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "validx/cy/chars.pyx", line 168, in validx.cy.chars.Str.__call__
TypeError: __call__() got an unexpected keyword argument '__context'

Tested with Python versions: 3.10.12, 3.11.9, 3.12.3