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

TypeError: a bytes-like object is required, not 'str' #1765

Closed
1 task done
wgordon17 opened this issue Mar 13, 2023 · 2 comments · Fixed by #1766
Closed
1 task done

TypeError: a bytes-like object is required, not 'str' #1765

wgordon17 opened this issue Mar 13, 2023 · 2 comments · Fixed by #1766
Labels
🐛 bug Something isn't working

Comments

@wgordon17
Copy link

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

Steps to reproduce

pdm add -v model-bakery==1.3.3

Actual behavior

Adding packages to default dependencies: model-bakery==1.3.3
STATUS: Resolving dependencies
pdm.termui: ======== Start resolving requirements ========
pdm.termui:   model-bakery==1.3.3
pdm.termui:   python>=3.11
pdm.termui:   Adding requirement model-bakery==1.3.3
pdm.termui:   Adding requirement python>=3.11
pdm.termui: ======== Starting round 0 ========
STATUS: Resolving: new pin python>=3.11
pdm.termui: Pinning: python None
pdm.termui: ======== Ending round 0 ========
pdm.termui: ======== Starting round 1 ========
pdm.termui:   Adding requirement b''(from model-bakery 1.3.3)
Traceback (most recent call last):
  File "/opt/homebrew/bin/pdm", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/homebrew/Cellar/pdm/2.4.8/libexec/lib/python3.11/site-packages/pdm/core.py", line 247, in main
    return Core().main(args)
           ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pdm/2.4.8/libexec/lib/python3.11/site-packages/pdm/core.py", line 181, in main
    raise cast(Exception, err).with_traceback(traceback) from None
  File "/opt/homebrew/Cellar/pdm/2.4.8/libexec/lib/python3.11/site-packages/pdm/core.py", line 176, in main
    f(project, options)
  File "/opt/homebrew/Cellar/pdm/2.4.8/libexec/lib/python3.11/site-packages/pdm/cli/commands/add.py", line 57, in handle
    actions.do_add(
  File "/opt/homebrew/Cellar/pdm/2.4.8/libexec/lib/python3.11/site-packages/pdm/cli/actions.py", line 271, in do_add
    resolved = do_lock(project, strategy, tracked_names, reqs, dry_run=dry_run, hooks=hooks)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pdm/2.4.8/libexec/lib/python3.11/site-packages/pdm/cli/actions.py", line 94, in do_lock
    mapping, dependencies = resolve(
                            ^^^^^^^^
  File "/opt/homebrew/Cellar/pdm/2.4.8/libexec/lib/python3.11/site-packages/pdm/resolver/core.py", line 35, in resolve
    result = resolver.resolve(requirements, max_rounds)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pdm/2.4.8/libexec/lib/python3.11/site-packages/resolvelib/resolvers.py", line 521, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pdm/2.4.8/libexec/lib/python3.11/site-packages/resolvelib/resolvers.py", line 402, in resolve
    failure_causes = self._attempt_to_pin_criterion(name)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pdm/2.4.8/libexec/lib/python3.11/site-packages/resolvelib/resolvers.py", line 238, in _attempt_to_pin_criterion
    criteria = self._get_updated_criteria(candidate)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pdm/2.4.8/libexec/lib/python3.11/site-packages/resolvelib/resolvers.py", line 229, in _get_updated_criteria
    self._add_to_criteria(criteria, requirement, parent=candidate)
  File "/opt/homebrew/Cellar/pdm/2.4.8/libexec/lib/python3.11/site-packages/resolvelib/resolvers.py", line 172, in _add_to_criteria
    if not criterion.candidates:
  File "/opt/homebrew/Cellar/pdm/2.4.8/libexec/lib/python3.11/site-packages/resolvelib/structs.py", line 127, in __bool__
    next(iter(self))
  File "/opt/homebrew/Cellar/pdm/2.4.8/libexec/lib/python3.11/site-packages/pdm/resolver/providers.py", line 241, in matches_gen
    yield from super_find()
               ^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pdm/2.4.8/libexec/lib/python3.11/site-packages/pdm/resolver/providers.py", line 139, in matches_gen
    candidates = self._find_candidates(reqs[0])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pdm/2.4.8/libexec/lib/python3.11/site-packages/pdm/resolver/providers.py", line 118, in _find_candidates
    can = make_candidate(requirement)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pdm/2.4.8/libexec/lib/python3.11/site-packages/pdm/models/candidates.py", line 592, in make_candidate
    return Candidate(req, name, version, link)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pdm/2.4.8/libexec/lib/python3.11/site-packages/pdm/models/candidates.py", line 147, in __init__
    link = req.as_file_link()  # type: ignore[attr-defined]
           ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pdm/2.4.8/libexec/lib/python3.11/site-packages/pdm/models/requirements.py", line 318, in as_file_link
    return Link(url)
           ^^^^^^^^^
  File "<string>", line 9, in __init__
  File "/opt/homebrew/Cellar/pdm/2.4.8/libexec/lib/python3.11/site-packages/unearth/link.py", line 54, in __post_init__
    if self.url.startswith(vcs_prefixes):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: a bytes-like object is required, not 'str'

Expected behavior

Adding packages to default dependencies: model-bakery
🔒 Lock successful
Changes are written to pdm.lock.
Changes are written to pyproject.toml.
Synchronizing working set with lock file: 4 to add, 0 to update, 0 to remove

  ✔ Install asgiref 3.6.0 successful
  ✔ Install model-bakery 1.3.3 successful
  ✔ Install sqlparse 0.4.3 successful
  ✔ Install django 4.1.7 successful

🎉 All complete!

Environment Information

PDM version:
  2.4.8
Python Interpreter:
  /Users/wgordon/.venv/bin/python (3.11)
Project Root:
  /Users/wgordon
Project Packages:
  None
{
  "implementation_name": "cpython",
  "implementation_version": "3.11.2",
  "os_name": "posix",
  "platform_machine": "arm64",
  "platform_release": "22.3.0",
  "platform_system": "Darwin",
  "platform_version": "Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000",
  "python_full_version": "3.11.2",
  "platform_python_implementation": "CPython",
  "python_version": "3.11",
  "sys_platform": "darwin"
}
@wgordon17 wgordon17 added the 🐛 bug Something isn't working label Mar 13, 2023
@frostming
Copy link
Collaborator

@frostming frostming closed this as not planned Won't fix, can't repro, duplicate, stale Mar 13, 2023
@wgordon17
Copy link
Author

That's great, thanks for the quick response @frostming! Is the issue specific to the lack of a comma (,) separating the minimum and maximum version requirements? https://github.com/model-bakers/model_bakery/blob/1.3.3/requirements.txt

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