Replies: 1 comment 2 replies
-
Converting to discussion. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, this is not an issue but rather a question and sorry for bothering you.
I'm trying to understand is it possible to partially override existing stubs (namely builtin
logging
module) with custom stubs.I have code that sets custom logger class for logging module that changes signature of methods (
info
etc).logging.getLogger
by default is annotated to returnLogger
instance but I want to redefine its signature to return custom class.I've found that PEP-561 says it should be possible but I had no luck (see the first item in linked paragraph). When I add my custom stubs (with single definition for
getLogger
) they override builtin module completely. Sologging.Logger
and everything else now reported as unknown name. This happens both to mypy and pyright.I've tried adding
__getattr__
definition in attempt to signify that stub is partial, but that (obviously) only makes type checker returnAny
for "missing" names.Also I tried adding
from logging import *
to my stub but that has no effect.Am I misreading the PEP? Am I doing things wrong?
Would appreciate any help
Beta Was this translation helpful? Give feedback.
All reactions