We recently cut a new-ish release of typed-ast that [adds a new field][0]
named `kind` to the `ast27.Str` and `ast3.Str` classes. This field
stores whatever string modifiers (like `b` or `u`) were present on the
original string.
As a note, I've confirmed that this field is indeed a str (and not
bytes) for ast27's Str class.
[0]: https://github.com/python/typed_ast/pull/49
For now specify Requirement.marker as Optional[Any] (as suggested by @srittau)
as we can't import packaging.markers (pkg_resource does that via runtime magic
in pkg_resources.external)
Closes#2961
* logging: Add logging.Logger().fatal()
fatal() is an alias for critical(): It is just another name for the same
implementation.
* logging: Fix logging.Logger().warn()
warn() was an alias for warning(), but got deprecated with Python3.
In Python2 warn() is just another name for the same method.
In Python3 they have their own implementations, which adds a deprecation
warning before calling the new function.
PS: LoggerAdapter in Python2 never has the warn() method, but Python3
still implements the deprecation wrapper function.
This class is not defined at runtime but it's used by
mypy internally to support TypedDict methods.
Use NoReturn in argument types for better type safety
when the related mypy plugin hook is not active.
When we import typeshed internally at Dropbox, somehow the fact that
these files are all stubs gets lost (it's a long story...). This
causes errors like this:
.../stdlib/2/ast.pyi:6: error: Name 'typing' already defined (by an import)
The quickest way around this is to rename the import to _typing.
This pull request modifies the contribution guidelines to clarify
when and where 'Any' should be used.
In particular, it clarifies that 'Any' is meant mainly to be used as
a "fallback" -- if it's not possible to express a certain type, if we're not
sure what the correct type in some case is, to avoid Union returns, etc...
It also explicitly notes that 'object' should be used over 'Any' when we
want to indicate that some function can accept literally anything.
Typing stubs this way probably won't impact most people, but does make
life a bit easier for people (like me) who want to restrict/forbid the
use of Any as much as possible.
* Use _ArgsType for logging.makeRecord
* The "args" argument is passed to LogMessage, so passing a tuple in is fine as
well.
* Use Mapping rather than Dict, see https://bugs.python.org/issue21172
It should be possible to ask for every object whether it looks like
an element. If only Elements are accepted, this function would always
return True.
Fixes#2629