Code Monkey home page Code Monkey logo

kayaku's People

Contributors

blueglassblock avatar greyelaina avatar programripper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

kayaku's Issues

New Python version support

Support handling things like types.UnionType based unions and GenericAlias based generics if necessary.

`dacite.exceptions.WrongTypeError` raised when a `bool` property is defined in `ConfigModel`

Describe the bug
dacite.exceptions.WrongTypeError raised when a bool property is defined in ConfigModel

Traceback (most recent call last):
  File "...\test.py", line 13, in <module>
    kayaku.create(TestConfig)
  File "...py3.10\lib\site-packages\kayaku\model.py", line 136, in create
    model_store.instance = from_dict(cls, container)
  File "...py3.10\lib\site-packages\dacite\core.py", line 68, in from_dict
    raise WrongTypeError(field_path=field.name, field_type=field.type, value=value)
dacite.exceptions.WrongTypeError: wrong value type for field "test_value" - should be "bool" instead of value "JWrapper(<kayaku.backend.types.JWrapper object at 0x000001F646D4B070>, value=True, __orig_class__=kayaku.backend.types.JWrapper[bool], json_before=[WhiteSpace(' ')], json_after=[])" of type "JWrapper"

To Reproduce
Code to reproduce the behavior:

if __name__ == "__main__":
    import kayaku

    kayaku.initialize({"{**}": "./test/{**}"})


    @kayaku.config("test")
    class TestConfig:
        test_value: bool = True


    kayaku.create(TestConfig)

    kayaku.bootstrap()
    kayaku.save_all()

Steps to reproduce the behavior:

  1. Run the code
  2. See file ./test/test.jsonc and ./test/test.schema.json with the correct value
  3. Run the code again
  4. See the error

Expected behavior
TestConfig should be properly read from file.

Enviroment

[tool.poetry.dependencies]
python = "^3.10"
kayaku = "0.5.0rc3"

Additional Content
Tested with more models, seems like only the one with bool property would raise this exception.

if __name__ == "__main__":
    import kayaku

    kayaku.initialize({"{**}": "./test/{**}"})


    @kayaku.config("test.str")
    class TestStrConfig:
        test_value: str = "test"


    @kayaku.config("test.int")
    class TestIntConfig:
        test_value: int = 0


    @kayaku.config("test.bool")
    class TestBoolConfig:
        test_value: bool = True


    kayaku.create(TestStrConfig)
    kayaku.create(TestIntConfig)
    kayaku.create(TestBoolConfig)

    kayaku.bootstrap()
    kayaku.save_all()

动态 bootstrap

鉴于 schema generator 已经换成自己写的了,所以动态更新是完全可能的

这将解决某些模块初始化就需要配置的问题

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.