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

Suggest using collections.abc etc, not typing (deprecated since 3.9) #46

Closed
34 tasks done
srittau opened this issue Aug 9, 2021 · 2 comments · Fixed by #324
Closed
34 tasks done

Suggest using collections.abc etc, not typing (deprecated since 3.9) #46

srittau opened this issue Aug 9, 2021 · 2 comments · Fixed by #324

Comments

@srittau
Copy link
Collaborator

srittau commented Aug 9, 2021

Affects:

  • AbstractSet (as collections.abc.Set)
  • AsyncContextManager (as contextlib.AbstractAsyncContextManager)
  • AsyncGenerator
  • AsyncIterable
  • AsyncIterator
  • Awaitable
  • ByteString
  • Callable
  • ChainMap (as collections.ChainMap)
  • Collection
  • Container
  • ContextManager (as contextlib.AbstractContextManager)
  • Coroutine
  • Counter (as collections.Counter)
  • DefaultDict (as collections.defaultdict)
  • Deque (as collections.Deque)
  • Generator
  • Hashable
  • ItemsView
  • Iterable
  • Iterator
  • KeysView
  • Mapping
  • MappingView
  • Match (as re.Match)
  • MutableMapping
  • MutableSequence
  • MutableSet
  • OrderedDict (as collections.OrderedDict)
  • Pattern (as re.Pattern)
  • Reversible
  • Sequence
  • Sized
  • ValuesView
@AlexWaygood

This comment was marked as resolved.

AlexWaygood added a commit that referenced this issue Apr 18, 2022
A regression test for python/typeshed#7635

Refs #46 (but doesn't quite close it).

Changes made:
* Expand Y027 to cover all objects in typing that are aliases to objects in collections.abc, except for AbstractSet
* Add new Y038 error code to forbid import AbstractSet from typing
* Change the error message in Y023 to make it clear that imports from collections.abc are now preferred to imports from typing.
* Refactor Y023 logic in pyi.py so as to quell flake8 from complaining that _check_import_or_attribute was getting too complex.
* Some small refactorings of test files to make them compatible with the new checks.
@AlexWaygood
Copy link
Collaborator

The only two left to do here are typing.Match and typing.Pattern. We can't check for that in typeshed until we drop support for 3.6, since re.Match and re.Pattern don't exist in Python 3.6, but I suppose we could add a check here before then.

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

Successfully merging a pull request may close this issue.

2 participants