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

UP035 --fix not working for Deque #3510

Closed
torarvid opened this issue Mar 14, 2023 · 5 comments · Fixed by #4420
Closed

UP035 --fix not working for Deque #3510

torarvid opened this issue Mar 14, 2023 · 5 comments · Fixed by #4420
Assignees
Labels
fixes Related to suggested fixes for violations

Comments

@torarvid
Copy link

When running ruff --fix test.py (Ruff 0.0.255), it doesn't change the Deque to deque

from typing import Deque

a: Deque[str]

However, interestingly, if we replace Deque with List, it does change to list

from typing import List

a: List[str]
@JonathanPlasse
Copy link
Contributor

@charliermarsh charliermarsh added the fixes Related to suggested fixes for violations label Mar 14, 2023
@charliermarsh
Copy link
Member

Yeah we can't fix this right now -- but, in theory, we should be able to.

@torarvid
Copy link
Author

Ah, I didn't know about #835, but I understand this issue depends on that. Thanks for the info 👍🏻

@tmke8
Copy link
Contributor

tmke8 commented May 14, 2023

This is the full list of typing imports that can be rewritten on Python 3.9:

  • collections.deque # typing.Deque
  • collections.defaultdict # typing.DefaultDict
  • collections.OrderedDict
  • collections.Counter
  • collections.ChainMap
  • collections.abc.Awaitable
  • collections.abc.Coroutine
  • collections.abc.AsyncIterable
  • collections.abc.AsyncIterator
  • collections.abc.AsyncGenerator
  • collections.abc.Iterable
  • collections.abc.Iterator
  • collections.abc.Generator
  • collections.abc.Reversible
  • collections.abc.Container
  • collections.abc.Collection
  • collections.abc.Callable
  • collections.abc.Set # typing.AbstractSet
  • collections.abc.MutableSet
  • collections.abc.Mapping
  • collections.abc.MutableMapping
  • collections.abc.Sequence
  • collections.abc.MutableSequence
  • collections.abc.ByteString
  • collections.abc.MappingView
  • collections.abc.KeysView
  • collections.abc.ItemsView
  • collections.abc.ValuesView
  • contextlib.AbstractContextManager # typing.ContextManager
  • contextlib.AbstractAsyncContextManager # typing.AsyncContextManager
  • re.Pattern # typing.Pattern, typing.re.Pattern
  • re.Match # typing.Match, typing.re.Match

source: https://peps.python.org/pep-0585/#implementation

@charliermarsh
Copy link
Member

The rewrites that don't require renames are already handled by UP035 (e.g., importing from collections import Counter instead of from typing import Counter).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixes Related to suggested fixes for violations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants