You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/tmp/main.py:5:13 - info: Type of "adapter.logger" is "Logger | LoggerAdapter"
/tmp/main.py:6:16 - error: Cannot access member "getChild" for type "LoggerAdapter"
Member "getChild" is unknown (reportGeneralTypeIssues)
With the proposed changes, pyright is able to infer the correct type of wrapped logger instance.
Diff from mypy_primer, showing the effect of this PR on open source code:
sphinx (https://github.com/sphinx-doc/sphinx.git)
- sphinx/util/logging.py: note: In member "handle" of class "SphinxLoggerAdapter":- sphinx/util/logging.py:140:9: error: Item "LoggerAdapter" of "Union[Logger, LoggerAdapter]" has no attribute "handle"
porcupine (https://github.com/Akuli/porcupine.git)
+ porcupine/plugins/langserver.py:129: error: Missing type parameters for generic type "LoggerAdapter" [type-arg]+ porcupine/plugins/langserver.py:143: error: Missing type parameters for generic type "LoggerAdapter" [type-arg]+ porcupine/plugins/langserver.py:323: error: Missing type parameters for generic type "LoggerAdapter" [type-arg]+ porcupine/plugins/langserver.py:724: error: Missing type parameters for generic type "LoggerAdapter" [type-arg]
@Akuli@srittau is it an issue that one has to distinct between type checking and runtime now? I mean, LoggerAdapter is not subscriptable, so the type has to be either quoted
@srittau@hoefling What would be the recommendation for inheritance? From what I understand importing annotations or quoting would not be as useful here
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The reason for this PR:
has no issues with
mypy, butpyrightreportsWith the proposed changes,
pyrightis able to infer the correct type of wrapped logger instance.