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

There is no way to create a SpecifierSet directly from one or more Specifiers #775

Closed
pfmoore opened this issue Jan 18, 2024 · 2 comments
Closed

Comments

@pfmoore
Copy link
Member

pfmoore commented Jan 18, 2024

The SpecifierSet constructor takes a string as input. But if you have a list of Specifier objects, there's no way to make a SpecifierSet from them without converting them back to strings and re-parsing.

Could a classmethod be added to build a specifier set from an iterable of Specifiers? It could be as simple as

@classmethod
def from_specifiers(cls, specs: Iterable[Specifier], prerelease: Optional[bool] = None):
    new_value = cls()
    new_value._specs = specs
    new_value._prereleases = prereleases
    return new_value

I'd be happy to create a PR for this if the idea is acceptable.

@pfmoore
Copy link
Member Author

pfmoore commented Jan 19, 2024

On reflection, this probably doesn't need a new classmethod - simply allowing construction from an iterator of Specifier instances should be fine.

I've created #777 implementing this.

@edgarrmondragon
Copy link
Contributor

I think this can be closed now that #777 was merged

@pfmoore pfmoore closed this as completed Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants