Skip to content

chore(packages): remove type errors#339

Closed
branchv wants to merge 1 commit into
python-poetry:masterfrom
branchv:mypy/packages
Closed

chore(packages): remove type errors#339
branchv wants to merge 1 commit into
python-poetry:masterfrom
branchv:mypy/packages

Conversation

@branchv
Copy link
Copy Markdown
Member

@branchv branchv commented May 1, 2022

Removes poetry.core.packages.* from the ignored list

Relates-to: python-poetry/poetry#5017

new._constraint = constraint
new._pretty_constraint = str(constraint)

new.set_constraint(constraint)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

before, this allowed constraint to be a str, although it seems the intention was for set_constraint to handle normalizing to VersionConstraint (as well as setting _pretty_constraint)

def set_constraint(self, constraint: str | VersionConstraint) -> None:

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 7, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
2.8% 2.8% Duplication

if isinstance(marker, (MultiMarker, MarkerUnion)):
groups[-1].append(
group_markers(marker.markers, isinstance(marker, MarkerUnion))
group_markers(marker.markers, isinstance(marker, MarkerUnion)) # type: ignore[arg-type]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I got stuck here (in combination with the changed return type), but maybe not worth thinking about it since group_markers is not required anymore with #347. (The output of it seems to be in a weird form for representing or anyway.)

@radoering
Copy link
Copy Markdown
Member

@branchvincent Can you rebase, please? (Sorry for the merge conflict.) 🙏

link = Link(path_to_url(p))

# it's a local file, dir, or url
dep: Dependency | None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion: initialize the value to None here, rather than later.

version = m.group("ver")

name = req.name or link.egg_fragment
name = cast(str, req.name or link.egg_fragment)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it's not clear what the intention of the (original) code is here: the name extracted only three lines previously is discarded here. So something has gone wrong and it would be good to take the opportunity to fix it.

My guess is that this whole fragment can be discarded (anyway that doesn't break any tests).

Copy link
Copy Markdown
Contributor

@dimbleby dimbleby May 15, 2022

Choose a reason for hiding this comment

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

(and if that's right then there are no users of egg_fragment left so maybe that can be discarded too)


self.extras = {}
self.requires_extras = []
self.extras: dict[str, list[str | Dependency]] = {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

pretty sure this should be dict[str, list[Dependency]]

groups = group_markers([marker])

requirements = {}
requirements: dict[str, list[list[tuple[str, str]]]] = {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is ConvertedMarkers isn't it?

op = ">"

version = constraint.min.text
version: Version | str = constraint.min.text
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

or I think this can always be a string (without needing annotation) if you set version = constraint.max.text a few lines later

@dimbleby dimbleby mentioned this pull request May 15, 2022
@neersighted
Copy link
Copy Markdown
Member

Closing this in favor of #354.

@branchv branchv deleted the mypy/packages branch May 16, 2022 16:18
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.

4 participants