PR #3269 added some version checks for the argument type to setLevel
and the existence of NullHandler. While these features weren't present
in early versions of Python 3, they *are* present in Python 2.7, which
leads to false positives.
The implementation of `logging.adapters.QueueHandler` and `logging.adapters.QueueListener` works great with `queue.SimpleQueue` too, so update the stub to reflect this.
The new queue.SimpleQueue class (introduced in 3.7) is faster but is not a Queue subclass as it doesn't implement task handling (`handle_task()` / `join()`) or queue bounds (raising `queue.Full` / `full()`). The logging handler / listener implementations do not make use of those features however.
Related Python bug, asking for an explicit documentation mention: https://bugs.python.org/issue37469
`logging.getLevelName()` can take either an `int` and returns a `str` or
a `str` and returns an `int` when the level name (`str`) or level
(`int`) is one of the registered log levels. If the value passed in
isn't one of the registered log levels, it returns the string `"level
%s" % lvl` where `lvl` is the value passed in to the function.
* 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.
* 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
Since Python 3.6 logging.FileHandler's filename argument can be a
PathLike object. Same for FileHandler's subclasses.
logging.basicConfig passes its filename argument to a FileHandler, so
this can be a PathLike object too.
Finally, logging.config.fileConfig passes its fname argument to
ConfigParser.read, which also takes a PathLike since version 3.6.1.
Standard implementation is:
```
def process(self, msg, kwargs):
kwargs["extra"] = self.extra
return msg, kwargs
```
so the signature is clearly `(Text, ...) -> (Text, ...)` (or `(str, ...) -> (str, ...)`, but following the other stubs here, I gather it's `Text`).
In python3 `RotatingFileHandler` is a subclass of `BaseRotatingHandler` which is a subclass of `FileHandler` which is a subclass of `StreamHandler` which as a `terminator` property but I'm getting a `"RotatingFileHandler" has no attribute "terminator"` error on my code.
The missing colon in the variable type annotation means that the type of stream is currently incorrectly determined to be of type ellipsis, rather than IO[str].
None is the default value for these two arguments to logging.Logger._log (which
most other stuff in logging delegates to).
I was getting errors in my codebase because mypy now distinguishes between Any
and Optional[Any].
"> (3,)" works but looks like the code is checking for Python 4.
"<= (3, 5)" was intended to check for versions up to and including 3.5, and probably works that
way in current type checkers. However, sys.version_info is actually a 5-tuple that is greater
than (3, 5), so a hypothetical type checker that uses the full version info would interpret
this check incorrectly.
This ensures that all version_info comparisons use <, >=, ==, or !=.