-
-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type hint vs Example mismatch #660
Comments
Hm, hard to say, the example just doesn't care, but maybe I should change it to The argument is the name of the logging method so I think it's better to keep it tight and let it be str – in what real-world scenario was that a problem? Since typing came many years after structlog's birth, not everything is super tight… |
To not violate our own type hints and intentions. Ref #660
If that is a no-op change, then sure, the example should be updated. I guess not having an example of what that should be would help as well?
There's some magic that I'm not understanding on how that works, but that's okay, I don't need to! 😉 As long as it works...
Observed here: https://github.com/pypi/warehouse/blob/10570d141ceb7377b374b425f80a4bf284df126c/warehouse/logging.py#L40 If replacing the effective |
I think you're overestimating what that argument does or where it's coming from. :) It's just a promise from structlog's bound loggers to pass it into the processor chain, because the bound loggers know what has been called. If your processors don't use the argument, don't worry about it, but in your example the correct way to call RENDERED would be |
Thanks! I'll do that. And since I saw that you've shipped the update to the examples, I think this is closed! |
Refs: hynek/structlog#660 (comment) Provide context links whenever possible. Signed-off-by: Mike Fiedler <[email protected]>
Refs: hynek/structlog#660 (comment) Provide context links whenever possible. Signed-off-by: Mike Fiedler <[email protected]>
Hello!
With structlog 24.4.0, I was combing through some mypy lint issues, and found that the example shown in the docs is basically what raises the issue, and wanted to understand which is intended to be correct.
Snippet taken from https://www.structlog.org/en/stable/api.html#structlog.processors.JSONRenderer specifically:
structlog/docs/api.rst
Lines 154 to 155 in 8a31eaa
Tested with mypy 1.10.1 and 1.11.2 (latest) - both show the same problem.
Considering the second argument to
__call__
:structlog/src/structlog/processors.py
Line 341 in 8a31eaa
str | None
or should the example be updated?name
value used at all, or could that be turned into_name: Any
or something to tell everyone we don't care about this variable?The text was updated successfully, but these errors were encountered: