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

Global repository setting results in TypeError #2330

Closed
jensstein opened this issue Oct 24, 2023 · 0 comments · Fixed by #2331
Closed

Global repository setting results in TypeError #2330

jensstein opened this issue Oct 24, 2023 · 0 comments · Fixed by #2331
Assignees
Labels
🐛 bug Something isn't working

Comments

@jensstein
Copy link
Contributor

  • [ ✓] I have searched the issue tracker and believe that this is not a duplicate.

I'm trying to set credentials for a private pypi repo globally in /etc/xdg/pdm/config.toml. The exact same settings work fine when added to the user-specific $XDG_CONFIG_HOME/pdm/config.toml but results in the error TypeError: pdm._types.RepositoryConfig() argument after ** must be a mapping, not RepositoryConfig when added to the global config.

Steps to reproduce

Write to /etc/xdg/pdm/config.toml

[pypi.azure-artifacts]
username = "__token__"
password = "password"

Try to initialize a project

$ pdm init -v .
Traceback (most recent call last):
  File "/usr/local/bin/pdm", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pdm/core.py", line 290, in main
    return Core().main(args or sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pdm/core.py", line 208, in main
    raise cast(Exception, err).with_traceback(traceback) from None
  File "/usr/local/lib/python3.11/site-packages/pdm/core.py", line 203, in main
    self.handle(project, options)
  File "/usr/local/lib/python3.11/site-packages/pdm/core.py", line 136, in handle
    self.ui.set_theme(project.global_config.load_theme())
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pdm/project/config.py", line 265, in load_theme
    return rich.theme.Theme({k[6:]: v for k, v in self.items() if k.startswith("theme.")})
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pdm/project/config.py", line 265, in <dictcomp>
    return rich.theme.Theme({k[6:]: v for k, v in self.items() if k.startswith("theme.")})
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen _collections_abc>", line 861, in __iter__
  File "/usr/local/lib/python3.11/site-packages/pdm/project/config.py", line 297, in __getitem__
    repo = self.get_repository_config(parts[1], parts[0])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pdm/project/config.py", line 400, in get_repository_config
    repositories[key] = RepositoryConfig(**v, name=key, config_prefix=prefix)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: pdm._types.RepositoryConfig() argument after ** must be a mapping, not RepositoryConfig

The same behaviour results from trying to add a package to an existing project with pdm add.

Actual behavior

pdm init dies with an error and no pyproject.toml is generated.

Expected behavior

pdm init results in the project being initialized.

Environment Information

# Paste the output of `pdm info && pdm info --env` below:
$ pdm info && pdm info --env
[TypeError]: pdm._types.RepositoryConfig() argument after ** must be a mapping, not RepositoryConfig
Add '-v' to see the detailed traceback

After deleting /etc/xdg/pdm/config.toml:

$ pdm info && pdm info --env
PDM version:
  2.9.3
Python Interpreter:
  /tmp/.venv/bin/python (3.11)
Project Root:
  /tmp
Local Packages:
  
{
  "implementation_name": "cpython",
  "implementation_version": "3.11.6",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "6.5.5-300.fc39.x86_64",
  "platform_system": "Linux",
  "platform_version": "#1 SMP PREEMPT_DYNAMIC Sat Sep 23 22:53:02 UTC 2023",
  "python_full_version": "3.11.6",
  "platform_python_implementation": "CPython",
  "python_version": "3.11",
  "sys_platform": "linux"
}
@jensstein jensstein added the 🐛 bug Something isn't working label Oct 24, 2023
@frostming frostming self-assigned this Oct 24, 2023
frostming added a commit that referenced this issue Oct 24, 2023
Fixes #2330

Signed-off-by: Frost Ming <me@frostming.com>
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 a pull request may close this issue.

2 participants