Soft deprecations¶
There are no plans to remove soft deprecated APIs.
re.match()andre.Pattern.match()are now soft deprecated in favor of the newre.prefixmatch()andre.Pattern.prefixmatch()APIs, which have been added as alternate, more explicit names. These are intended to be used to alleviate confusion around what match means by following the Zen of Python’s “Explicit is better than implicit” mantra. Most other language regular expression libraries use an API named match to mean what Python has always called search.We do not plan to remove the older
match()name, as it has been used in code for over 30 years. Code supporting older versions of Python should continue to usematch(), while new code should preferprefixmatch(). See prefixmatch() vs. match().(Contributed by Gregory P. Smith in gh-86519 and Hugo van Kemenade in gh-148100.)
The following typing-related classes are soft deprecated:
typing.Optionalin favor of the dedicated union syntax (X | None)typing.NoReturnin favor oftyping.Nevertyping.ForwardRefin favor ofannotationlib.ForwardReftypes.UnionTypein favor oftyping.Union(but see below)
Creating
typing.Unioninstances using the constructor is also deprecated. Use the dedicated union syntax (X | Y) instead.Explicitly inheriting from
typing.Genericis also deprecated. Use the dedicated syntax for generic functions, generic classes, and generic type aliases instead.