Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pydantic.mypy plugin to mypy configuration #10

Merged
merged 1 commit into from
Apr 7, 2024

Conversation

hmasdev
Copy link
Owner

@hmasdev hmasdev commented Apr 7, 2024

This pull request adds the pydantic.mypy plugin to the mypy configuration. This plugin will enhance the type checking capabilities of mypy and improve the accuracy of type inference.

This pull request also fixes the following bug:

 $ python -m simple_typing_application -c config.json
Traceback (most recent call last):
  File "~\.pyenv\pyenv-win\versions\3.10.11\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "~\.pyenv\pyenv-win\versions\3.10.11\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "D:\dev_libs\simple_typing_application\simple_typing_application\__main__.py", line 2, in <module>
    main()
  File "D:\dev_libs\simple_typing_application\venv\lib\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "D:\dev_libs\simple_typing_application\venv\lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "D:\dev_libs\simple_typing_application\venv\lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "D:\dev_libs\simple_typing_application\venv\lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "D:\dev_libs\simple_typing_application\simple_typing_application\main.py", line 45, in main
    sentence_generator = create_sentence_generator(config.sentence_generator_type, config.sentence_generator_config)  # noqa
  File "D:\dev_libs\simple_typing_application\simple_typing_application\sentence_generator\factory.py", line 51, in create_sentence_generator
    sentence_generator: BaseSentenceGenerator = sentence_generator_cls(**sentence_generator_config.model_dump())    # type: ignore # noqa
  File "D:\dev_libs\simple_typing_application\simple_typing_application\sentence_generator\openai_sentence_generator.py", line 32, in __init__
    self._llm = ChatOpenAI(
  File "D:\dev_libs\simple_typing_application\venv\lib\site-packages\langchain_core\load\serializable.py", line 120, in __init__
    super().__init__(**kwargs)
  File "D:\dev_libs\simple_typing_application\venv\lib\site-packages\pydantic\v1\main.py", line 341, in __init__
    raise validation_error
pydantic.v1.error_wrappers.ValidationError: 1 validation error for ChatOpenAI
api_key
  str type expected (type=type_error.str)

@hmasdev hmasdev self-assigned this Apr 7, 2024
@hmasdev hmasdev merged commit 631c817 into main Apr 7, 2024
52 checks passed
@hmasdev hmasdev deleted the fix-instantiation-bug branch April 7, 2024 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant