Skip to content

Comments

Don't warn for previously constraint dependencies#11091

Closed
konstin wants to merge 1 commit intomainfrom
konsti/dont-warn-for-second-req
Closed

Don't warn for previously constraint dependencies#11091
konstin wants to merge 1 commit intomainfrom
konsti/dont-warn-for-second-req

Conversation

@konstin
Copy link
Member

@konstin konstin commented Jan 30, 2025

Fixes the case reported at #8870 (comment)

@konstin konstin force-pushed the konsti/dont-warn-for-second-req branch from dcb55b5 to 8be831e Compare January 30, 2025 12:52
Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

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

What if a dependency is listed twice in the same optional group, once with a lower bound and once without?

@konstin
Copy link
Member Author

konstin commented Jan 30, 2025

You mean like this? They are already not emitting warnings. (Which looks like a false negative? They are not showing warnings even without the bounds.)

[project]
name = "foo"
version = "0.1.0"
requires-python = ">=3.10"
dependencies = []

[project.optional-dependencies]
case_a = [
  "anyio",
  "anyio>=4,<5",
]
case_b1 = [
  "numpy",
]
case_b2 = [
  "numpy>=2",
]

locations: &'data IndexLocations,
workspace: &'data Workspace,
lower_bound: LowerBound,
constrained_packages: &'data HashSet<PackageName>,
Copy link
Member

Choose a reason for hiding this comment

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

We should be using FxHashSet by default.

// Support recursive editable inclusions.
if has_sources
&& !constrained_packages.contains(&requirement.name)
&& requirement.version_or_url.is_none()
Copy link
Member

Choose a reason for hiding this comment

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

So, should we remove this? I think it's redundant now? (Also, isn't this wrong? It seems to only look at None, and not the lower bound?)

bounds: LowerBound,
) -> RequirementSource {
match &requirement.version_or_url {
None => {
Copy link
Member

Choose a reason for hiding this comment

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

I'm actually slightly confused now, hmm... You have this has_lower_bound check in get_constrained_packages, but here we're not looking at the specifier... We're just warning if there's no constraint.

@charliermarsh
Copy link
Member

Becoming slightly confused about the difference between how constrained_packages is populated and when we choose to show these warnings (i.e., checking has_lower_bound vs. checking if the specifiers are None).

@konstin konstin closed this Feb 3, 2025
zanieb added a commit that referenced this pull request Feb 3, 2025
These are noisy relative to the effect they have on the user. It seems
better to prioritize hints on poor resolutions. Notably, it seems hard
to make these "not noisy" ref #11091.

Does not include the "lowest" resolution mode, in which lower bounds are
critical.
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.

2 participants