Skip to content
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

Logger.getChild subclass compatible typehint #6609

Merged
merged 4 commits into from
Dec 21, 2021
Merged

Logger.getChild subclass compatible typehint #6609

merged 4 commits into from
Dec 21, 2021

Conversation

randolf-scholz
Copy link
Contributor

Proposed fix for #6606

stdlib/logging/__init__.pyi Outdated Show resolved Hide resolved
randolf-scholz and others added 2 commits December 16, 2021 13:24
Co-authored-by: Akuli <akuviljanen17@gmail.com>
@github-actions

This comment has been minimized.

Copy link
Collaborator

@Akuli Akuli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'll wait for another maintainer to merge this and confirm whether this is a good idea.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@JelleZijlstra
Copy link
Member

Looking at https://github.com/python/cpython/blob/main/Lib/logging/__init__.py#L1750 I don't think this is right. There is no guarantee that getChild will return the same type as the logger it is called on.

@JelleZijlstra
Copy link
Member

Ah, I just found python/typing#980 which makes a good argument that this is useful in practice.

@randolf-scholz
Copy link
Contributor Author

Ah, I just found python/typing#980 which makes a good argument that this is useful in practice.

Well, this is a thread I opened today before opening the issue here. I linked this thread also in the issue. #6606

@AlexWaygood
Copy link
Member

AlexWaygood commented Dec 16, 2021

Ah, I just found python/typing#980 which makes a good argument that this is useful in practice.

Well, this is a thread I opened today before opening the issue here. I linked this thread also in the issue. #6606

It might be good to include a link to the thread in a comment

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

ppb-vector (https://github.com/ppb/ppb-vector)
-   File "/tmp/mypy_primer/old_mypy/venv/bin/mypy", line 8, in <module>
+   File "/tmp/mypy_primer/new_mypy/venv/bin/mypy", line 8, in <module>
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/__main__.py", line 11, in console_entry
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/__main__.py", line 11, in console_entry
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/main.py", line 87, in main
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/main.py", line 87, in main
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/main.py", line 165, in run_build
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/main.py", line 165, in run_build
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 179, in build
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 179, in build
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 254, in _build
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 254, in _build
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2644, in dispatch
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2644, in dispatch
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2802, in load_graph
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2802, in load_graph
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 1888, in __init__
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 1888, in __init__
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2016, in parse_file
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2016, in parse_file
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 1955, in wrap_context
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 1955, in wrap_context
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2046, in parse_file
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2046, in parse_file
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 788, in parse_file
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 788, in parse_file
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/parse.py", line 25, in parse
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/parse.py", line 25, in parse
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 168, in parse
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 168, in parse
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 329, in visit
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 329, in visit
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 496, in visit_Module
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 496, in visit_Module
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 367, in translate_stmt_list
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 367, in translate_stmt_list
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 329, in visit
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 329, in visit
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 509, in visit_FunctionDef
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 509, in visit_FunctionDef
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 607, in do_func_def
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 607, in do_func_def
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 439, in as_required_block
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 439, in as_required_block
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 367, in translate_stmt_list
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 367, in translate_stmt_list
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 327, in visit
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 327, in visit

pylox (https://github.com/sco1/pylox)
-   File "/tmp/mypy_primer/old_mypy/venv/bin/mypy", line 8, in <module>
+   File "/tmp/mypy_primer/new_mypy/venv/bin/mypy", line 8, in <module>
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/__main__.py", line 11, in console_entry
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/__main__.py", line 11, in console_entry
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/main.py", line 87, in main
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/main.py", line 87, in main
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/main.py", line 165, in run_build
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/main.py", line 165, in run_build
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 179, in build
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 179, in build
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 254, in _build
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 254, in _build
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2644, in dispatch
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2644, in dispatch
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2802, in load_graph
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2802, in load_graph
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 1888, in __init__
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 1888, in __init__
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2016, in parse_file
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2016, in parse_file
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 1955, in wrap_context
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 1955, in wrap_context
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2046, in parse_file
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 2046, in parse_file
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 788, in parse_file
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/build.py", line 788, in parse_file
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/parse.py", line 25, in parse
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/parse.py", line 25, in parse
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 168, in parse
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 168, in parse
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 329, in visit
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 329, in visit
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 496, in visit_Module
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 496, in visit_Module
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 367, in translate_stmt_list
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 367, in translate_stmt_list
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 329, in visit
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 329, in visit
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 729, in visit_ClassDef
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 729, in visit_ClassDef
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 439, in as_required_block
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 439, in as_required_block
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 367, in translate_stmt_list
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 367, in translate_stmt_list
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 329, in visit
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 329, in visit
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 509, in visit_FunctionDef
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 509, in visit_FunctionDef
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 607, in do_func_def
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 607, in do_func_def
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 439, in as_required_block
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 439, in as_required_block
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 367, in translate_stmt_list
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 367, in translate_stmt_list
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 327, in visit
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.10/site-packages/mypy/fastparse.py", line 327, in visit

@JelleZijlstra JelleZijlstra merged commit 4f9b45f into python:master Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants