Repository navigation
Add some missing logging features - #5388
Conversation
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
| def usesTime(self) -> bool: ... # undocumented | ||
|
|
||
| class BufferingFormatter: | ||
| linefmt: Formatter |
There was a problem hiding this comment.
I think line format could be a string like: '%(something)s %(something)s'. So, linefmt should be changed to:
linefmt: Union[str, Formatter]There was a problem hiding this comment.
Technically it can be anything with a .format() method, even a string. But that .format() method will be called with only one argument, a log record object. It is possible to create a string that formats them in a useful way, such as "{0.name}: {0.msg}", although that doesn't seem to be how it's intended to be used.
There was a problem hiding this comment.
So the correct fix would be a protocol? We could leave as Any for the moment, though.
There was a problem hiding this comment.
Honestly I would just use Formatter. It's what the author of the code intended. (This is old code, likely written before str.format was a thing)
There was a problem hiding this comment.
I was under the same impression as @Akuli, intended to be a Formatter
|
|
||
| class BufferingFormatter: | ||
| linefmt: Formatter | ||
| def __init__(self, linefmt: Optional[Formatter] = ...) -> None: ... |
There was a problem hiding this comment.
Same here:
def __init__(self, linefmt: Optional[Union[str, Formatter]] = ...) -> None: ...
srittau
left a comment
There was a problem hiding this comment.
If someone want to change Formatter to a protocol, they can do it in a separate PR. I'm fine with it being a concrete class for now.
This handles #5257, #5015, and changes two
typetoType[...]for #343Note I annotatedvalidation_pattern,IDENTIFIER, andextMatchasAnysince I cannot do this, which would make a variable, not a type alias.Please note that
SMTPHandler.passwordis not always created depending on what is passed in! But since I know of no workarounds for maybe-exsiting-attributes and the documents suggest:I have added it
password: str.I am not fixing everything I see in this PR, I have left a lot of
logging.configas-is