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

Removing type ignore comments from cli package #7932

Merged
merged 1 commit into from
May 13, 2020

Conversation

deveshks
Copy link
Contributor

@deveshks deveshks commented Mar 29, 2020

First stab at fixing #7764

I have initially removed the ones which can be removed and are more straightforward to remove. There are still some remaining which are slightly more non-trivial which I will try in the next commits

news/7764.feature Outdated Show resolved Hide resolved
src/pip/_internal/cli/progress_bars.py Outdated Show resolved Hide resolved
@pradyunsg pradyunsg added the type: maintenance Related to Development and Maintenance Processes label Mar 30, 2020
@deveshks deveshks force-pushed the remove-type-ignore-from-cli branch from ffd9844 to e144c7b Compare March 30, 2020 14:36
@deveshks
Copy link
Contributor Author

deveshks commented Apr 10, 2020

Hi @pradyunsg

As per my comment here #7932 (comment) justifying my usage of getattr, is there another approach I can take here? Maybe just doing self.index = None ,self.avg=None should be a good option as well.

I'll also tackle some of the remaining # type: ignore comments in another PR

@pradyunsg
Copy link
Member

I don't want us to add getattr here because of mypy - in general, if we have to add something that we won't do while writing normal code, like a getattr w/ a static string, we shouldn't do that.

Could you revert those changes? We can revisit them in a separate PR.

@deveshks
Copy link
Contributor Author

I don't want us to add getattr here because of mypy - in general, if we have to add something that we won't do while writing normal code, like a getattr w/ a static string, we shouldn't do that.

Could you revert those changes? We can revisit them in a separate PR.

No worries, I will revert them. Should I then try to handle other # type: ignore comments in this PR, or else we can merge this PR with whatever changes I have made here, and revisit removing other comments in a separate PR.

@pradyunsg
Copy link
Member

pradyunsg commented Apr 10, 2020

we can merge this PR with whatever changes I have made here, and revisit removing other comments in a separate PR.

When in doubt, I have a bias toward smaller PRs. :)

@pradyunsg pradyunsg removed the request for review from uranusjr April 10, 2020 13:42
@deveshks deveshks force-pushed the remove-type-ignore-from-cli branch 2 times, most recently from e482c74 to ed709c1 Compare April 10, 2020 14:06
@deveshks
Copy link
Contributor Author

deveshks commented Apr 10, 2020

we can merge this PR with whatever changes I have made here, and revisit removing other comments in a separate PR.

When in doubt, I have a bias toward smaller PRs. :)

Agreed @pradyunsg . I have gone ahead and reverted the changes which removed # type: ignore comments at the expense of getattr. I will think of a better to remove them for such situations.

If rest of the changes look good, please go ahead and approve/merge the PR 😊

@deveshks
Copy link
Contributor Author

Hi @pradyunsg , @xavfernandez

If the changes look good here, could I get this PR approved/merged 😊

@deveshks
Copy link
Contributor Author

If there are no more changes needed to this PR, may I get this PR approved?

@deveshks deveshks requested a review from uranusjr May 12, 2020 19:27
Copy link
Contributor

@gutsytechster gutsytechster left a comment

Choose a reason for hiding this comment

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

Does the #type: ignore comment here at line 274 also raises some error?

@deveshks deveshks force-pushed the remove-type-ignore-from-cli branch from ed709c1 to 89f248c Compare May 13, 2020 09:51
@deveshks
Copy link
Contributor Author

deveshks commented May 13, 2020

Does the #type: ignore comment here at line 274 also raises some error?

Yep, If I remove the type: ignore and do something like

def DownloadProgressProvider(progress_bar, max=None):
    # type: (str, Optional[int]) -> Callable[[Iterable[bytes]] , Iterator[bytes]]
    if max is None or max == 0:
        return BAR_TYPES[progress_bar][1]().iter
    else:
        return BAR_TYPES[progress_bar][0](max=max).iter

I get error: "WindowsMixin" has no attribute "iter" on return BAR_TYPES[progress_bar][1]().iter

There is python/mypy#5868 on why this fails and https://mypy.readthedocs.io/en/stable/more_types.html#mixin-classes which provides some suggestions about how to fix it, which I might take a stab at in subsequent PRs after this one is approved/merged.

@pradyunsg
Copy link
Member

We should add warn_unused_ignores = True in our mypy global configuration in a follow up PR.

@pradyunsg pradyunsg merged commit d911a9f into pypa:master May 13, 2020
@deveshks deveshks deleted the remove-type-ignore-from-cli branch May 13, 2020 12:21
@deveshks
Copy link
Contributor Author

Thanks @pradyunsg for the approval and merge 😊

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: maintenance Related to Development and Maintenance Processes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants