Skip to content

Fix __qualname__ AttributeError in config parsing with Pydantic >= 2.10#180

Merged
gpauloski merged 2 commits intomainfrom
config-parse-error
Nov 27, 2024
Merged

Fix __qualname__ AttributeError in config parsing with Pydantic >= 2.10#180
gpauloski merged 2 commits intomainfrom
config-parse-error

Conversation

@gpauloski
Copy link
Copy Markdown
Contributor

Description

Fixes the following error in the config parsing that appeared with the release of Pydantic 2.10.0. Note that the fix is not compatible with Python 3.8, so the max version of Pydantic is limited for Python 3.8. (TaPS will remove Python 3.8 support soon so this should not matter much.)

taps/run/parse.py:193: in parse_args_to_config
    cli_settings: CliSettingsSource[Config] = CliSettingsSource(
.tox/py39/lib/python3.9/site-packages/pydantic_settings/sources.py:1165: in __init__
    self._connect_root_parser(
.tox/py39/lib/python3.9/site-packages/pydantic_settings/sources.py:1574: in _connect_root_parser
    self._add_parser_args(
.tox/py39/lib/python3.9/site-packages/pydantic_settings/sources.py:1687: in _add_parser_args
    self._add_parser_submodels(
.tox/py39/lib/python3.9/site-packages/pydantic_settings/sources.py:1789: in _add_parser_submodels
    self._add_parser_args(
.tox/py39/lib/python3.9/site-packages/pydantic_settings/sources.py:1656: in _add_parser_args
    kwargs['metavar'] = self._metavar_format(field_info.annotation)
.tox/py39/lib/python3.9/site-packages/pydantic_settings/sources.py:1886: in _metavar_format
    return self._metavar_format_recurse(obj).replace(', ', ',')
.tox/py39/lib/python3.9/site-packages/pydantic_settings/sources.py:1867: in _metavar_format_recurse
    return self._metavar_format_choices(list(map(self._metavar_format_recurse, self._get_modified_args(obj))))
.tox/py39/lib/python3.9/site-packages/pydantic_settings/sources.py:1874: in _metavar_format_recurse
    list(map(self._metavar_format_recurse, self._get_modified_args(obj))), obj_qualname=obj.__qualname__

Fixes N/A

Type of Change

  • Bug (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds or improves functionality)
  • Internal (refactoring, performance, and testing)
  • Breaking (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (no changes to the code)
  • Development (CI workflows, packages, templates, etc.)
  • Package (package dependencies and versions)

Testing

Test pass again.

Pull Request Checklist

Please confirm the PR meets the following requirements.

  • Relevant tags are added (breaking, bug, documentation, enhancement, package, etc.).
  • Code changes pass pre-commit (e.g., ruff, mypy, etc.).
  • Tests have been added to show the fix is effective or that the new feature works.
  • New and existing unit tests pass locally with the changes.
  • Docs have been updated and reviewed if relevant.

@gpauloski gpauloski added the bug Something isn't working label Nov 27, 2024
@gpauloski gpauloski merged commit bcfd663 into main Nov 27, 2024
@gpauloski gpauloski deleted the config-parse-error branch November 27, 2024 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant