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

Replace bitwise AND with logical AND (which is breaking my use of UV) #3197

Closed
wants to merge 1 commit into from

Conversation

theNewFlesh
Copy link

Pull Request Checklist

  • A news fragment is added in news/ describing what is new.
  • Test cases added for changed code.

uv.py uses bitwise and (&) for logic in which logical and (and) is required. When using UV with PDM, PDM throws a TypeError on these lines. This change resolves that.

Copy link
Collaborator

@frostming frostming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because that is not a logical and, that is an intersection operation. can you show how would it raise typeerror when both sides are not None?

@theNewFlesh
Copy link
Author

theNewFlesh commented Oct 1, 2024

I am looking for the error in my logs.

It was something like:
TypeError: unsupported operand type(s) for &: Marker and bool in uv.py

I ran some test code to see if bitwise AND gives the same error and it does.

I'll post the error if I can find it.

@theNewFlesh
Copy link
Author

theNewFlesh commented Oct 2, 2024

Well I'm not finding it in the logs, but I found an old search I performed on the exact error:

TypeError: unsupported operand type(s) for &: 'Marker' and 'bool'

On line 192 I believe.

I am switching over some existing projects from vanilla PDM to PDM with UV. Most have worked fine, but one often throws this error when I pdm sync.

@clement-tourriere
Copy link
Contributor

Hello, I have the exact same error. Sadly I can't really provide an easy reproductible scenario, but from the code I guess there is parenthesis missing:

parent_marker & (marker or get_marker("")).is_empty()

raises the error: *** TypeError: unsupported operand type(s) for &: 'Marker' and 'bool'

but

(parent_marker & (marker or get_marker(""))).is_empty()

works well.

I guess the fix could be something like:

        def marker_match(marker: Marker | None) -> bool:
            return not ((parent_marker & (marker or get_marker(""))).is_empty())

frostming added a commit that referenced this pull request Oct 10, 2024
@frostming
Copy link
Collaborator

Hello, I have the exact same error. Sadly I can't really provide an easy reproductible scenario, but from the code I guess there is parenthesis missing:

Thank you, you found the real bug! Too many parentheses made me overlook it.

@frostming frostming closed this Oct 10, 2024
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.

3 participants