Commit Graph
90 Commits
Author SHA1 Message Date
Kaushal RohitandGitHub 36f2ffa07e Added missing SysLogHandler types (#4630) 2020-10-07 19:02:54 -07:00
04c74640f0 Removed imported symbols that are not accessed or re-exported (#4387)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2020-08-05 22:49:17 -07:00
karl dingandGitHub 8f50cd9d0e Add missing syslog facility codes (#4366)
Add support for the following syslog facilities:

  - LOG_NTP
  - LOG_SECURITY
  - LOG_CONSOLE
  - LOG_SOLCRON

In addition, reorder the entries to match the CPython implementation to
make it easier to read.
2020-07-27 12:34:12 +02:00
Vegard StikbakkeandGitHub 51fd8b2a06 Fix Filter.filter return type - bool, not int (#4358) 2020-07-24 20:25:06 +02:00
Sebastian RittauandGitHub 5e76f51930 Upgrade to isort 5 (#4323)
This now also reformats imports not at the top of files.
2020-07-16 07:01:57 -07:00
Jelle ZijlstraandGitHub 0142a87da8 adjust isort config (#4290)
Fixes #4288.

- Default imports to THIRD_PARTY, so in effect we merge the FIRST_PARTY and THIRD_PARTY stubs. This means import order is no longer affected by whether typing_extensions is installed locally.
- Treat typing_extensions, _typeshed and some others as standard library modules.

Note that isort master is very different from the latest release; we'll have to do something
different if and when the next isort release comes out.
2020-06-29 00:00:21 -07:00
Jelle ZijlstraandGitHub 5d553c9584 apply black and isort (#4287)
* apply black and isort

* move some type ignores
2020-06-28 13:31:00 -07:00
Jelle ZijlstraandGitHub 43e93f803f use _typeshed's Path aliases (#4214) 2020-06-10 20:57:09 -07:00
ShantanuGitHubhauntsaninja <>
df6136c4ac logging: various fixes (#4196)
* logging.disable: update for py37

* RootLogger: fix __init__

* shutdown: add undocumented parameter

* MemoryHandler: add flushOnClose in py36

* NTEventLogHandler: fix dllname type

* makeSocket: add undocumented parameter

* SysLogHandler: fix socktype type

Co-authored-by: hauntsaninja <>
2020-06-07 14:05:29 -07:00
Jaromir LatalandGitHub 4ab1d6f0ae [stdlib][logging] Make level default in logging.disable for 3.7+ (#4197) 2020-06-07 13:09:22 -07:00
ShantanuGitHubhauntsaninja <>
db819480a5 logging: fix argument names (#4181)
* logging: fix argument names

* logging: filter method improvements

Co-authored-by: hauntsaninja <>
2020-06-04 19:32:03 -07:00
Michael HandGitHub a1c6566abe [Add stub entry for logging._srcfile] (#3840)
- While this appears to be private, it's also documented as available
  to set here: https://docs.python.org/3/howto/logging.html#optimization
  - Did *not* update `logging.logThreads` et al to match the
  documentation as it may be more appropriate to update the
  documentation to set to `False` rather than to `0` based on how these
  are used

Type further narrowed based on known type of a parameter to
`os.normcase`
2020-05-27 19:42:33 -07:00
Oleg HöflingandGitHub 830295074c add _log() method to Logger and LoggerAdapter (#3749)
Signed-off-by: Oleg Höfling <oleg.hoefling@gmail.com>
2020-02-21 20:46:54 -08:00
47409f3e25 Add missing stubs for logging.handlers.WatchedFileHandler. (#3686)
Co-authored-by: CyrilRoelandteNovance <cyril@redhat.com>
2020-01-29 08:27:12 -08:00
ShantanuandSebastian Rittau 1b5c2dfa1f logging: update for py38 (#3595)
* logging: add stacklevel parameter everywhere

* logging: add force to basicConfig

* logging: add validate to Formatter
2020-01-14 19:45:38 +01:00
Jelle ZijlstraandSebastian Rittau 97f830030c Simplify WatchedFileHandler.__init__ (#3506)
Fixes #3502
2019-12-03 14:54:29 +01:00
Nikola ForróandSebastian Rittau 92aa1ee9c2 logging.handlers: Add BufferingHandler.buffer (#3402)
Signed-off-by: Nikola Forró <nforro@redhat.com>
2019-10-23 14:33:06 +02:00
Florian BruhinandSebastian Rittau bb12f3bdea Fix argument type for logging.Formatter.formatTime (#3343)
datefmt can be None - that's what the default value is: https://docs.python.org/3/library/logging.html#logging.Formatter.formatTime
2019-10-11 14:39:24 +02:00
Michael J. SullivanandSebastian Rittau eeb8daa467 Remove some spurious version checks in logging (#3292)
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.
2019-10-02 08:09:21 +02:00
Guido van RossumandGitHub b336182b69 Fix some errors with --disallow-any-generics (#3276)
See #3267. Covers all of stdlib/2and3.
2019-09-29 09:15:27 -07:00
brianjyoungandSebastian Rittau d1ed2b275f Updated logging type stub (#3269) 2019-09-27 13:28:08 +02:00
Evgeny DedovandSebastian Rittau 0dea39cb3c make basicConfig parameters Optional[...] (#3170) 2019-08-07 10:43:05 +02:00
BradandSebastian Rittau bd2d0fcc85 Add hints for 3 globals from logging/__init__.py (#3159) 2019-07-30 17:28:13 +02:00
Connor BrintonandSebastian Rittau df8ecf5a67 Fix incorrectly named parameters in logging module (#3148) 2019-07-25 21:29:55 +02:00
Martijn PietersandJelle Zijlstra e1e5c83795 QueueHandler / QueueListener accept SimpleQueue too (#3098)
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
2019-07-01 07:47:30 -07:00
Callum RyanandSebastian Rittau 1726b31013 Change WatchedFileHandler to inherit from FileHandler (#2947) 2019-05-02 21:55:56 +02:00
Utkarsh GuptaandJelle Zijlstra df953ca385 config.pyi: Return a Thread instance (#2945)
Fixes #2938
2019-05-02 06:22:51 -04:00
Michael LeeandSebastian Rittau efb67946f8 Use variable annotations everywhere (#2909) 2019-04-13 10:40:52 +02:00
Lawrence ChanandSebastian Rittau 4856458251 Add logging.Formatter.formatMessage method (#2850) 2019-03-11 08:46:21 +01:00
Eric TrautandSebastian Rittau 20b3b54460 Changed parameter name of several methods in logging module from 'lvl' to 'level' to match the implementation. Use in a keyword arg of 'lvl' results in runtime errors. (#2840) 2019-03-10 03:04:31 +01:00
ЕвгенийandSebastian Rittau 6f09ccb63d logging: inherit TimedRotatingFileHandler from Handler (#2738) 2019-01-17 13:54:59 +01:00
Michael NoseworthyandSebastian Rittau e8c1111d13 Fix logging.getLevelName() type hints (#2730)
`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.
2019-01-17 13:40:03 +01:00
Ilya KonstantinovandSebastian Rittau 93150dc0fa LoggerAdapter.log argument lvl -> level (#2722) 2019-01-04 09:03:56 +01:00
Savo KovačevićandSebastian Rittau 8542916231 Add missing currentframe to logging module (#2712) 2018-12-23 19:57:15 +01:00
Philipp HahnandSebastian Rittau bf410fb9ef Logging (#2687)
* 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.
2018-12-17 15:39:01 +01:00
Florian BruhinandSebastian Rittau f2e842b2d9 Fix handling of logging args (#2635)
* 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
2018-11-29 12:56:01 +01:00
Keith GrayandSebastian Rittau f9f4e50004 Added logging port constants to logging.handlers stub (#2617)
Closes #2616
2018-11-21 18:08:34 +01:00
Joey WilhelmandSebastian Rittau 292cbf1a35 Correct the param type for mapPriority (#2578)
Closes #2577
2018-11-01 23:55:01 +01:00
Sebastian RittauandJelle Zijlstra 006a79220f Flake8 fixes (#2549)
* Fix over-indented continuation lines

* Fix under-indented continuation lines

* Fix whitespace around default operator problems

* Limit line lengths

* Fix inconsistent files
2018-10-24 07:20:53 -07:00
Jan TeskeandJelle Zijlstra 94a1b09d1d Support PathLike arguments in the logging module. (#2500)
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.
2018-10-01 20:13:37 -07:00
Emil HessmanandSebastian Rittau d70a6cbcc0 Add missing instance attributes to logging.LoggerAdapter (#2462) 2018-09-18 20:23:04 +02:00
Matthew ChristopherandSebastian Rittau 110ebf4bfe Add exc_text to LogRecord (#2461) 2018-09-18 13:39:05 +02:00
Matt RobinsonandSebastian Rittau c1eb946324 Add name attribute to logging.Handler (#2459)
* Add name attribute to logging.Handler
* Replace some older type comments with variable annotations around the addition line.
2018-09-17 19:36:49 +02:00
Yusuke MiyazakiandJelle Zijlstra 6192cce9d9 Avoid using string literals in type annotations (#2294) 2018-07-02 20:23:29 -07:00
Philipp HahnandJelle Zijlstra f8041d08db logging.BASIC_FORMAT also for python2.7 (#2283) 2018-06-27 20:14:06 -07:00
Roy WilliamsandGuido van Rossum 52c02a2364 Allow Any type to be acceptable for the msg parameter in `logging.{info, warn, error, ...} (#1776)
The stdlib accepts any value here as long as it is castable to a string:

https://github.com/python/cpython/blob/3.6/Lib/logging/__init__.py#L336
https://github.com/python/cpython/blob/2.7/Lib/logging/__init__.py#L319-L330

Ideally this would use Protocols but I don't see them in use in typeshed yet.
2018-06-11 16:10:31 -07:00
Scott BeldenandJelle Zijlstra 84cafafe73 TracebackType is optional (#2202) 2018-06-09 16:22:50 -07:00
Ilya KonstantinovandJelle Zijlstra 128a49a32d Fix LoggerAdapter.process first argument (#2153)
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`).
2018-05-21 08:27:16 -07:00
João SantosandJelle Zijlstra afeecb478b RotatingFileHandler has a terminator property (#1952)
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.
2018-03-25 08:11:01 -07:00
Mark AmeryandJelle Zijlstra 0c2249fbd6 Add FileHandler properties (#1834)
Fixes #1833.
2018-02-16 17:21:30 -08:00