Skip to content

Issue with builtins.slice Signature #832

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

Closed
froomzy opened this issue Jan 13, 2017 · 4 comments
Closed

Issue with builtins.slice Signature #832

froomzy opened this issue Jan 13, 2017 · 4 comments

Comments

@froomzy
Copy link
Contributor

froomzy commented Jan 13, 2017

I have been trying mypy out, and I am hitting something I don't understand. I have the following line of code:

NZD = Currency(name='New Zealand Dollars', abbreviation='NZD', slice=slice(3, None, None), format='NZ${price:.2f}')

When I run mypy over it I get the following error (in python3.5 virtualenv):

mypy --strict-optional -p lists
lists\constants.py:13: error: Argument 2 to "slice" has incompatible type None; expected "int"

It seems that slice has a type signature of slice(int, int, int), but to get the behavior I want (give me everything in the string after the third character) I need to pass in a None. I think they should be Optional[int]s rather than ints.

Hopefully that makes sense.

@gvanrossum
Copy link
Member

I think you can just submit a PR to fix this.

I expect that the attributes should also be Optional[int]?

There are also two issues discussing bigger changes to slice, but I think they are somewhat controversial:

@froomzy
Copy link
Contributor Author

froomzy commented Jan 13, 2017

Righto. I have not done a pull request before, so time to go learn about that.

@JelleZijlstra
Copy link
Member

Looks like this can be closed since the PR was merged.

@gvanrossum
Copy link
Member

Which makes me think, reviewers should be more careful to edit the commit summary, message body, and auto-close text (preferably "fixes #x" or "closes #x" -- the latter if it's not really a fix but e.g. a feature request).

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

No branches or pull requests

3 participants