[issue43463] typing.get_type_hints with TYPE_CHECKING imports / getting hints for single argument

2021-03-10 Thread Ken Jin
Change by Ken Jin : -- nosy: +kj ___ Python tracker <https://bugs.python.org/issue43463> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue43355] __future__.annotations breaks inspect.signature()

2021-03-03 Thread Ken Jin
Ken Jin added the comment: @eric.smith, here's a summarized version. I hope it helps: def foo(x: str) -> str: ... In Python 3.7 - 3.9 with from __future__ import annotations, inspect.signature sees foo's parameter as: Without the future import (and also in Python 3.10): The rea

[issue43257] get_type_hints evaluates class variables before type hints

2021-02-19 Thread Ken Jin
Ken Jin added the comment: Hmm I noticed this occurs in Python 3.9 but not 3.10. If you insert ``from __future__ import annotations`` at the start of your code, it stops erroring. Anyways, I don't think this is dataclass specific, the following code using a plain class also errors

[issue42967] [security] urllib.parse.parse_qsl(): Web cache poisoning - `; ` as a query args separator

2021-02-15 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +23323 pull_request: https://github.com/python/cpython/pull/24536 ___ Python tracker <https://bugs.python.org/issue42

[issue41559] Add support for PEP 612 (Parameter Specification Variables) to typing.py

2021-02-12 Thread Ken Jin
Ken Jin added the comment: Hi Guido, after a month of observing how people stumbled over the related collections.abc.Callable bugs, and experience from implementing this PEP, I learnt a few things which I think may interest you: Previously it was *recommended* that everything in typing

[issue8264] [doc] hasattr doesn't show private (double underscore) attributes exist

2021-02-12 Thread Ken Jin
Ken Jin added the comment: Thanks for merging this Ethan! I think we can close this now (unless you want me to backport this to 3.9 and 3.8 as well). -- ___ Python tracker <https://bugs.python.org/issue8

[issue41824] Docs for typing.ForwardRef don't state that it was added in 3.7

2021-02-09 Thread Ken Jin
Ken Jin added the comment: I think we can close this now. Thanks for reporting it Dominic, and thanks Guido for all your help! -- ___ Python tracker <https://bugs.python.org/issue41

[issue41824] Docs for typing.ForwardRef don't state that it was added in 3.7

2021-02-09 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +23285 pull_request: https://github.com/python/cpython/pull/24495 ___ Python tracker <https://bugs.python.org/issue41

[issue41824] Docs for typing.ForwardRef don't state that it was added in 3.7

2021-02-09 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +23284 pull_request: https://github.com/python/cpython/pull/24494 ___ Python tracker <https://bugs.python.org/issue41

[issue41824] Docs for typing.ForwardRef don't state that it was added in 3.7

2021-02-09 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +23283 pull_request: https://github.com/python/cpython/pull/24493 ___ Python tracker <https://bugs.python.org/issue41

[issue42128] Structural Pattern Matching (PEP 634)

2021-02-09 Thread Ken Jin
Ken Jin added the comment: Hi Daniel, wow thanks for the offer! My GitHub username is Fidget-Spinner. I'm not sure about the grammar file either. Oh, thanks for mentioning the tutorial recommendation by the SC, I'll keep that in mind

[issue42128] Structural Pattern Matching (PEP 634)

2021-02-09 Thread Ken Jin
Ken Jin added the comment: Guido and Brandt, may I take a stab at the docs for this? I'll probably base most of it off PEP 636's tutorial. Relevant parts of the docs that I've identified: reference/lexical_analysis.rst reference/compound_stmts.rst reference/grammar.rst # this probably needs

[issue42882] Restarting the interpreter causes UB on 3.10.0a4

2021-02-04 Thread Ken Jin
Change by Ken Jin : -- nosy: +kj nosy_count: 2.0 -> 3.0 pull_requests: +23250 pull_request: https://github.com/python/cpython/pull/24440 ___ Python tracker <https://bugs.python.org/issu

[issue43119] asyncio.Queue.put never yields if the queue is unbounded

2021-02-04 Thread Ken Jin
Ken Jin added the comment: Thanks for the minimal reproducer. I've tested it on 3.9.0 and 3.10a4 and they seem to exhibit the same behavior too. Out of genuine curiosity (I don't mean to question if this *is* a bug, it seems like a trap for users): why not place an ``await asyncio.sleep(0

[issue42988] Information disclosure via pydoc -p: /getfile?key=path allows to read arbitrary file on the filesystem

2021-01-26 Thread Ken Jin
Ken Jin added the comment: @Serhiy, While this approach solves the getfile problem, I don't think this will solve the other problem of pydoc leaking secrets stored in python files: Quoting from Marc-Andre Lemburg's message: > the tool also makes available all Python modules which

[issue42967] [security] urllib.parse.parse_qsl(): Web cache poisoning - `; ` as a query args separator

2021-01-24 Thread Ken Jin
Ken Jin added the comment: Dear all, now that Adam has signed the CLA, I have closed my PR in favor of Adam's because I think 2 open PRs might split everyone's attention. Instead, I'll focus on reviewing Adam's PR. Sorry for any inconvenience caused

[issue42967] [security] urllib.parse.parse_qsl(): Web cache poisoning - `; ` as a query args separator

2021-01-23 Thread Ken Jin
Ken Jin added the comment: I updated the PR to take in a sequence of separators from the user - eg: >>> urllib.parse.parse_qsl('a=1=2;c=3', separators=('&', ';')) [('a', '1'), ('b', '2'), ('c', '3')] >>> urllib.parse.parse_qsl('a=1=2;c=3', separators=('&',)) [('a'

[issue43006] Changed behaviour of inspect.signature() in Python 3.10

2021-01-23 Thread Ken Jin
Ken Jin added the comment: For anyone interested, I went to do some digging on the 3 issues Zac listed: 1. Similar to the first message, this is caused by inspect.getfullarg/signature using get_type_hints in Py 3.10. get_type_hints internally converts None to NoneType. 2. I don't know

[issue42967] [security] urllib.parse.parse_qsl(): Web cache poisoning - `; ` as a query args separator

2021-01-23 Thread Ken Jin
Ken Jin added the comment: @Adam: >I haven't noticed, I'm sorry. I don't mind closing mine, just thought it could >be a nice first contribution. No worries :), please don't close yours. > Our PRs are different though - I feel like if we are to implement this, we >

[issue43006] Changed behaviour of inspect.signature() in Python 3.10

2021-01-23 Thread Ken Jin
Ken Jin added the comment: > This is correct for typing.get_type_hints(), but *not* for > inspect.signature(). I therefore suspect that this is an accidental > side-effect from support for PEP-563 deferred evaluation of annotations. Spot on about PEP 563 becoming the defa

[issue43004] No type variables left in collections.abc.Callable

2021-01-22 Thread Ken Jin
Ken Jin added the comment: This seems to be a duplicate of Issue40494. It has already been fixed in Python 3.10, and in Python 3.9.2 (which isn't out yet). You can see the what's new for it here https://docs.python.org/3/whatsnew/3.9.html#notable-changes-in-python-3-9-2. The expected

[issue42988] Information disclosure via pydoc -p: /getfile?key=path allows to read arbitrary file on the filesystem

2021-01-22 Thread Ken Jin
Ken Jin added the comment: I have updated the PR to do the following: - removed html_getfile - implement a unique secret as suggested above Now it says: >>> python.exe -m pydoc -b Server ready at http://localh

[issue42967] [security] urllib.parse.parse_qsl(): Web cache poisoning - `; ` as a query args separator

2021-01-22 Thread Ken Jin
Ken Jin added the comment: Adam, I linked a PR 2 days ago here https://github.com/python/cpython/pull/24271 , it has the test suite passing and the appropriate changes to cgi.py. Would you like to review it? Or since you submitted a PR, would you prefer I close mine instead

[issue42988] Information disclosure via pydoc -p: /getfile?key=path allows to read arbitrary file on the filesystem

2021-01-21 Thread Ken Jin
Ken Jin added the comment: I created a PR to remove the getfile function - now it just places the hyperlinked file path there but clicking on it won't render the file contents. Personally I agree with Marc-Andre Lemburg's comments on how _url_handler probably has other vulnerabilities

[issue42988] Information disclosure via pydoc -p: /getfile?key=path allows to read arbitrary file on the filesystem

2021-01-21 Thread Ken Jin
Change by Ken Jin : -- keywords: +patch nosy: +kj nosy_count: 4.0 -> 5.0 pull_requests: +23104 stage: -> patch review pull_request: https://github.com/python/cpython/pull/24285 ___ Python tracker <https://bugs.python.org/i

[issue42967] [security] urllib.parse.parse_qsl(): Web cache poisoning - `; ` as a query args separator

2021-01-20 Thread Ken Jin
Ken Jin added the comment: FWIW, a surprising amount of things rely on treating ';' as a valid separator in the standard test suite. >From just a cursory look: test_cgi test_urlparse A change in the public API of urlparse will also require a change in cgi.py's FieldStor

[issue42967] [security] urllib.parse.parse_qsl(): Web cache poisoning - `; ` as a query args separator

2021-01-20 Thread Ken Jin
Change by Ken Jin : -- keywords: +patch nosy: +kj nosy_count: 4.0 -> 5.0 pull_requests: +23094 stage: -> patch review pull_request: https://github.com/python/cpython/pull/24271 ___ Python tracker <https://bugs.python.org/i

[issue42392] remove the deprecated 'loop' parameter asyncio API

2021-01-19 Thread Ken Jin
Change by Ken Jin : -- nosy: +kj nosy_count: 5.0 -> 6.0 pull_requests: +23078 pull_request: https://github.com/python/cpython/pull/24256 ___ Python tracker <https://bugs.python.org/issu

[issue42965] Optional callable raises TypeError

2021-01-19 Thread Ken Jin
Ken Jin added the comment: Hello, this issue is a byproduct of issue42195. It has already been fixed on Python 3.10, and on Python 3.9.2 (which isn't out yet). You can see the what's new for it here https://docs.python.org/3/whatsnew/3.9.html#notable-changes-in-python-3-9-2. The expected

[issue42377] allow typing.cast with TYPE_CHECKING

2021-01-15 Thread Ken Jin
Ken Jin added the comment: Sorry, I don't think this is a typing module issue. The NameError stems from what you mentioned: 'A' not being defined since TYPE_CHECKING evaluates to false at runtime. This would raise an error in any Python code, not just typing. The equivalent

[issue41824] Docs for typing.ForwardRef don't state that it was added in 3.7

2021-01-15 Thread Ken Jin
Change by Ken Jin : -- keywords: +patch nosy: +kj nosy_count: 2.0 -> 3.0 pull_requests: +23048 stage: -> patch review pull_request: https://github.com/python/cpython/pull/24224 ___ Python tracker <https://bugs.python.org/i

[issue42904] get_type_hints does not provide localns for classes

2021-01-12 Thread Ken Jin
Change by Ken Jin : -- keywords: +patch pull_requests: +23026 stage: -> patch review pull_request: https://github.com/python/cpython/pull/24201 ___ Python tracker <https://bugs.python.org/issu

[issue42904] get_type_hints does not provide localns for classes

2021-01-12 Thread Ken Jin
Ken Jin added the comment: > Fidget-Spinner, are you interested in taking this? Sure thing! Please give me some time to look at it - I don't really use the runtime type validation stuff from typing (I usually defer that to 3rd party libraries), so I need to familiarize myself fi

[issue42783] asyncio.sleep(0) idiom is not documented

2021-01-07 Thread Ken Jin
Change by Ken Jin : -- nosy: +kj nosy_count: 5.0 -> 6.0 pull_requests: +22981 stage: backport needed -> patch review pull_request: https://github.com/python/cpython/pull/24153 ___ Python tracker <https://bugs.python.org/i

[issue42834] [subinterpreters] Convert "global" static variable caches in _json to heap variables

2021-01-05 Thread Ken Jin
Change by Ken Jin : -- keywords: +patch pull_requests: +22952 stage: -> patch review pull_request: https://github.com/python/cpython/pull/24121 ___ Python tracker <https://bugs.python.org/issu

[issue42834] [subinterpreters] Convert "global" static variable caches in _json to heap variables

2021-01-05 Thread Ken Jin
New submission from Ken Jin : _json currently uses a few static locals for caching of PyUnicode and one Exception object. This patch aims to move them to the heap. Apologies if this isn't the right way to track subinterpreter issues, I took a look at issue36876 but it seemed like a meta

[issue42195] Inconsistent __args__ between typing.Callable and collections.abc.Callable

2021-01-02 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +22893 pull_request: https://github.com/python/cpython/pull/24059 ___ Python tracker <https://bugs.python.org/issue42

[issue41559] Add support for PEP 612 (Parameter Specification Variables) to typing.py

2021-01-02 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +22890 pull_request: https://github.com/python/cpython/pull/24056 ___ Python tracker <https://bugs.python.org/issue41

[issue41559] Add support for PEP 612 (Parameter Specification Variables) to typing.py

2021-01-01 Thread Ken Jin
Ken Jin added the comment: I have just one more PR - one that converts genericalias nested lists to tuples by default. It'll simplify the code a little bit and prepare 3.9.x for PEP 612. -- ___ Python tracker <https://bugs.python.org/issue41

[issue42786] Different repr for collections.abc.Callable and typing.Callable

2020-12-30 Thread Ken Jin
Ken Jin added the comment: You're welcome, and yes you're right! You can read the news item for it here https://docs.python.org/3/whatsnew/3.9.html#notable-changes-in-python-3-9-2. The expected release date for Python 3.9.2 is Monday, 2021-02-15 according to PEP 596 https://www.python.org

[issue42786] Different repr for collections.abc.Callable and typing.Callable

2020-12-30 Thread Ken Jin
Ken Jin added the comment: This was addressed in issue42195 and issue40494 as you pointed out :). It has been fixed in Python 3.10. Unfortunately the backport didn't make it in time for Python 3.9.1, and will come in Python 3.9.2 instead. Sadly there's not much to do about that. On 3.10

[issue41559] Add support for PEP 612 (Parameter Specification Variables) to typing.py

2020-12-29 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +22842 pull_request: https://github.com/python/cpython/pull/24000 ___ Python tracker <https://bugs.python.org/issue41

[issue42740] typing.py get_args and get_origin should support PEP 604 and 612

2020-12-27 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +22808 pull_request: https://github.com/python/cpython/pull/23963 ___ Python tracker <https://bugs.python.org/issue42

[issue42741] Sync 3.9's whatsnew document in 3.10 with 3.9 branch

2020-12-25 Thread Ken Jin
Change by Ken Jin : -- keywords: +patch pull_requests: +22794 stage: -> patch review pull_request: https://github.com/python/cpython/pull/23943 ___ Python tracker <https://bugs.python.org/issu

[issue42741] Sync 3.9's whatsnew document in 3.10 with 3.9 branch

2020-12-25 Thread Ken Jin
New submission from Ken Jin : On the 3.10 branch, the what's new document for 3.9 isn't synced with the one on the 3.9 branch. Currently it's missing two entries: macOS 11.0 (Big Sur) and Apple Silicon Mac support issue41100 (next one's my fault, sorry) collections.abc.Callable changes

[issue42740] typing.py get_args and get_origin should support PEP 604 and 612

2020-12-25 Thread Ken Jin
Change by Ken Jin : -- keywords: +patch pull_requests: +22793 stage: -> patch review pull_request: https://github.com/python/cpython/pull/23942 ___ Python tracker <https://bugs.python.org/issu

[issue42740] typing.py get_args and get_origin should support PEP 604 and 612

2020-12-25 Thread Ken Jin
New submission from Ken Jin : Currently get_args doesn't work for PEP 604 Union: >>> get_args(int | str) or new Callables with PEP 612: >>> P = ParamSpec('P) >>> get_args(Callable[P, int]) ([~P], ) get_origin doesn't work with PEP 604 Unions: >>> get

[issue40494] collections.abc.Callable and type variables

2020-12-25 Thread Ken Jin
Ken Jin added the comment: Now that issue42195 has been resolved by subclassing types.GenericAlias, can this be closed? On 3.9 and 3.10: >>> import typing, collections.abc >>> T = typing.TypeVar('T') >>> C2 = collections.abc.Callable[[T], T] >>> C2[int]

[issue42732] Buildbot s390x Fedora LTO + PGO 3.x fails intermittently

2020-12-24 Thread Ken Jin
Ken Jin added the comment: Oops, you're right! Sorry, I'll close this issue. Anyways I realized I had the wrong hunch - I was looking at a different part of the logs. -- resolution: -> duplicate stage: -> resolved status: open -&g

[issue42732] Buildbot s390x Fedora LTO + PGO 3.x fails intermittently

2020-12-24 Thread Ken Jin
New submission from Ken Jin : Dear core developers, I noticed that for many recent commits, the s390x Fedora LTO + PGO 3.x buildbot often fails. Here's an error log:: gcc -pthread -fno-semantic-interposition -flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -g -Xlinker

[issue41559] Add support for PEP 612 (Parameter Specification Variables) to typing.py

2020-12-23 Thread Ken Jin
Ken Jin added the comment: Thanks for the extremely helpful reviews and help in this Guido! Sure, I'll probably start work on that next week, slightly busy with life right now. After that I'll work on docs. -- ___ Python tracker <ht

[issue42195] Inconsistent __args__ between typing.Callable and collections.abc.Callable

2020-12-23 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +22766 pull_request: https://github.com/python/cpython/pull/23915 ___ Python tracker <https://bugs.python.org/issue42

[issue42699] Use `.join(k for k in g)` instead of `.join([k for k in g])`

2020-12-20 Thread Ken Jin
Ken Jin added the comment: Sorry for intruding, but I thought I'd offer some rudimentary, non-scientific benchmarks for this: [MSC v.1928 32 bit (Intel)] on win32 # a debug build of python, no compiler optimizations import timeit # gen comp timeit.timeit("''.join(str(_) for _ in

[issue42675] Document changes made in bpo-42195

2020-12-19 Thread Ken Jin
Change by Ken Jin : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue42195] Inconsistent __args__ between typing.Callable and collections.abc.Callable

2020-12-18 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +22717 pull_request: https://github.com/python/cpython/pull/23852 ___ Python tracker <https://bugs.python.org/issue42

[issue42675] Document changes made in bpo-42195

2020-12-18 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +22716 pull_request: https://github.com/python/cpython/pull/23852 ___ Python tracker <https://bugs.python.org/issue42

[issue42195] Inconsistent __args__ between typing.Callable and collections.abc.Callable

2020-12-18 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +22702 pull_request: https://github.com/python/cpython/pull/23839 ___ Python tracker <https://bugs.python.org/issue42

[issue42195] Inconsistent __args__ between typing.Callable and collections.abc.Callable

2020-12-18 Thread Ken Jin
Change by Ken Jin : -- pull_requests: -22699 ___ Python tracker <https://bugs.python.org/issue42195> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue42195] Inconsistent __args__ between typing.Callable and collections.abc.Callable

2020-12-18 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +22699 pull_request: https://github.com/python/cpython/pull/23839 ___ Python tracker <https://bugs.python.org/issue42

[issue42675] Document changes made in bpo-42195

2020-12-18 Thread Ken Jin
Change by Ken Jin : -- keywords: +patch pull_requests: +22698 stage: -> patch review pull_request: https://github.com/python/cpython/pull/23839 ___ Python tracker <https://bugs.python.org/issu

[issue42675] Document changes made in bpo-42195

2020-12-18 Thread Ken Jin
New submission from Ken Jin : A whatsnew is probably needed as this change causes backwards incompatibility in some code working with Python 3.9.0 and 3.9.1. I think the patch for Python 3.9.2 should mention that a DeprecationWarning is emitted for some invalid use cases, which

[issue42195] Inconsistent __args__ between typing.Callable and collections.abc.Callable

2020-12-14 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +22621 pull_request: https://github.com/python/cpython/pull/23765 ___ Python tracker <https://bugs.python.org/issue42

[issue41559] Add support for PEP 612 to typing.py

2020-12-10 Thread Ken Jin
Ken Jin added the comment: The pyre version in their __init__.py looks like they took your advice for letting the static checker do the work wholeheartedly. I'm not in favour of type checking either. Just that the pre-existing code does it for me. Not type checking when seeing ~P

[issue41559] Add support for PEP 612 to typing.py

2020-12-10 Thread Ken Jin
Ken Jin added the comment: > and was surprised that C.__parameters__ was (T,) instead of (T, P). Alright, I just fixed that :). I'm now encountering many problems with how typing works which prevent what PEP 612 declare as valid from not throwing an error (these are all examples copied f

[issue41559] Add support for PEP 612 to typing.py

2020-12-08 Thread Ken Jin
Ken Jin added the comment: I have a one question: Should ParamSpec be treated as a type of TypeVar? This mostly pertains to adding it to __parameters__ of generic aliases. Type substitution/chaining, seems inappropiate for it right now. Thanks for your help

[issue41559] Add support for PEP 612 to typing.py

2020-12-08 Thread Ken Jin
Change by Ken Jin : -- keywords: +patch nosy: +kj nosy_count: 1.0 -> 2.0 pull_requests: +22569 stage: needs patch -> patch review pull_request: https://github.com/python/cpython/pull/23702 ___ Python tracker <https://bugs.python.org/i

[issue42576] Passing keyword arguments to types.GenericAlias causes a hard crash

2020-12-06 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +22530 pull_request: https://github.com/python/cpython/pull/23663 ___ Python tracker <https://bugs.python.org/issue42

[issue42576] Passing keyword arguments to types.GenericAlias causes a hard crash

2020-12-06 Thread Ken Jin
Ken Jin added the comment: Thanks for taking the time to review this! I forgot to specify this only affects debug builds in the news entry. I'm opening a PR to edit that because I don't want people to mistake it for an actual interpreter-crashing bug in the release build (that would

[issue42576] Passing keyword arguments to types.GenericAlias causes a hard crash

2020-12-05 Thread Ken Jin
Change by Ken Jin : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue42576] Passing keyword arguments to types.GenericAlias causes a hard crash

2020-12-05 Thread Ken Jin
Change by Ken Jin : -- keywords: +patch pull_requests: +22524 stage: -> patch review pull_request: https://github.com/python/cpython/pull/23656 ___ Python tracker <https://bugs.python.org/issu

[issue42576] Passing keyword arguments to types.GenericAlias causes a hard crash

2020-12-05 Thread Ken Jin
New submission from Ken Jin : I noticed that passing keyword arguments to types.GenericAlias's __new__ causes the interpreter to hard crash and exit due to an assertion failure: import types types.GenericAlias(bad=float) Result: Assertion failed: PyTuple_CheckExact(kwnames), file

[issue42195] Inconsistent __args__ between typing.Callable and collections.abc.Callable

2020-11-30 Thread Ken Jin
Ken Jin added the comment: FWIW, current code for extracting args type and return type from Callable seems to be something like this (at least from the typing module): arg_types = __args__[:-1] return_type = __args__[-1] Once ParamSpec is added in, library authors would need to check

[issue8264] [doc] hasattr doesn't show private (double underscore) attributes exist

2020-11-25 Thread Ken Jin
Change by Ken Jin : -- nosy: +kj nosy_count: 4.0 -> 5.0 pull_requests: +22400 pull_request: https://github.com/python/cpython/pull/23513 ___ Python tracker <https://bugs.python.org/iss

[issue42195] Inconsistent __args__ between typing.Callable and collections.abc.Callable

2020-11-22 Thread Ken Jin
Ken Jin added the comment: A possible workaround for _PosArgs in collections.abc without depending on typing could be like this: _PosArgs = type('_PosArgs', (tuple, ), {}) This would help out the future type proposals too, because GenericAlias accepts non-type args. __args__ of Callable

[issue42195] Inconsistent __args__ between typing.Callable and collections.abc.Callable

2020-11-22 Thread Ken Jin
Ken Jin added the comment: @guido, Aesthetics-wise, I agree that ((int, int), str) looks by far the best. My gripe with it lies with the implementation - almost every function in typing currently assumes that every object in __args__ is a type, having (int, int) - the tuple object

[issue42195] Inconsistent __args__ between typing.Callable and collections.abc.Callable

2020-11-19 Thread Ken Jin
Ken Jin added the comment: I tried to implement Callable[[int, int], str] as ((int, int), str). However, it breaks much of typing's tests and requires recursion to account for the nested tuples, in both typing, and in the C implementation of GenericAlias. I'd like to humbly propose a less

[issue42345] Equality of typing.Literal depends on the order of arguments

2020-11-18 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +22279 pull_request: https://github.com/python/cpython/pull/23386 ___ Python tracker <https://bugs.python.org/issue42

[issue42345] Equality of typing.Literal depends on the order of arguments

2020-11-18 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +22278 pull_request: https://github.com/python/cpython/pull/23385 ___ Python tracker <https://bugs.python.org/issue42

[issue42332] add __weakref__ to types.GenericAlias

2020-11-15 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +22200 pull_request: https://github.com/python/cpython/pull/23309 ___ Python tracker <https://bugs.python.org/issue42

[issue42345] Equality of typing.Literal depends on the order of arguments

2020-11-15 Thread Ken Jin
Ken Jin added the comment: @Guido and @Ivan, Should Literals de-duplicate values in its __args__ similar to Union? PEP 586 states that: > Literal[v1, v2, v3] is equivalent to Union[Literal[v1], Literal[v2], > Literal[v3]] Naturally, a Union de-duplicates values, so I was won

[issue42354] Tuple unpacking with * causes SyntaxError in with ... as ...

2020-11-14 Thread Ken Jin
Ken Jin added the comment: This is a duplicate of issue bpo-41979, which was already fixed in this merged PR https://github.com/python/cpython/pull/22611 and backported to 3.9. The example code does not error on the latest 3.10. I'm guessing that the bugfix will come in 3.9.1 since the fix

[issue42317] Docs of `typing.get_args`: Mention that due to caching of typing generics the order of arguments for Unions can be different from the one of the returned tuple

2020-11-12 Thread Ken Jin
Ken Jin added the comment: Dominik, would you like to submit a PR for this :) ? -- ___ Python tracker <https://bugs.python.org/issue42317> ___ ___ Python-bug

[issue42332] add __weakref__ to types.GenericAlias

2020-11-12 Thread Ken Jin
Change by Ken Jin : -- keywords: +patch nosy: +kj nosy_count: 2.0 -> 3.0 pull_requests: +22147 stage: -> patch review pull_request: https://github.com/python/cpython/pull/23250 ___ Python tracker <https://bugs.python.org/i

[issue42245] concurrent.futures.ProcessPoolExecutor freezes depending on complexity

2020-11-11 Thread Ken Jin
Ken Jin added the comment: Danil, thanks for finding the cause behind this. Could you check if the new behavior in Python 3.8 and higher has the same problem on your machine (without your fix)? multiprocessing on MacOS started using spawn in 3.8, and I was wondering if it that fixed

[issue42317] Docs of `typing.get_args`: Mention that due to caching of typing generics the order of arguments for Unions can be different from the one of the returned tuple

2020-11-11 Thread Ken Jin
Ken Jin added the comment: You're right, currently this happens for 2 reasons: 1. _SpecialGenericAlias (used by List), caches its __getitem__. (As you already pointed out :) ) 2. _UnionGenericAlias (Union)'s __hash__ is `hash(frozenset(self.__args__))`. i.e. Unions with different args

[issue42294] [C API] Add new C functions with more regular reference counting like PyTuple_GetItemRef()

2020-11-10 Thread Ken Jin
Change by Ken Jin : -- nosy: +kj nosy_count: 5.0 -> 6.0 pull_requests: +22130 pull_request: https://github.com/python/cpython/pull/23227 ___ Python tracker <https://bugs.python.org/issu

[issue42233] GenericAlias does not support union type expressions

2020-11-08 Thread Ken Jin
Change by Ken Jin : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue42280] The list of standard generic collections is incomplete

2020-11-07 Thread Ken Jin
Ken Jin added the comment: Dear Jack, good catch! My only worry is that if we make the list exhaustive, it would be too lengthy, or that it might not be feasible to continuously update it every time a new generic type supports the feature. Maybe a line somewhere to mention that most

[issue20774] collections.deque should ship with a stdlib json serializer

2020-11-05 Thread Ken Jin
Ken Jin added the comment: Sorry to butt into this conversation, but I wanted to add that I have interest in this feature - deques are the fourth most common container types I use in Python. Is there any way I can help to get this PR across the finish line? So far I've forked the PR

[issue40816] Add missed AsyncContextDecorator to contextlib

2020-11-05 Thread Ken Jin
Change by Ken Jin : -- nosy: +kj nosy_count: 5.0 -> 6.0 pull_requests: +22076 pull_request: https://github.com/python/cpython/pull/23164 ___ Python tracker <https://bugs.python.org/issu

[issue42245] concurrent.futures.ProcessPoolExecutor freezes depending on complexity

2020-11-02 Thread Ken Jin
Ken Jin added the comment: Hmm apologies I'm stumped then. The only things I managed to surmise from xgboost's and scikit-learn's GitHub issues is that this is a recurring issue specifically when using GridSearchCV : Threads with discussions on workarounds: https://github.com/scikit-learn

[issue42245] concurrent.futures.ProcessPoolExecutor freezes depending on complexity

2020-11-02 Thread Ken Jin
Ken Jin added the comment: Hello, it would be great if you can you provide more details. Like your Operating System and version, how many logical CPU cores there are on your machine, and lastly the exact Python version with major and minor versions included (eg. Python 3.8.2

[issue42195] Inconsistent __args__ between typing.Callable and collections.abc.Callable

2020-11-01 Thread Ken Jin
Ken Jin added the comment: Dear Guido, from what I can see in the typing module, _CallableType already casts the args list to a tuple before creating the __CallableGenericAlias, so it should support cacheing. This is taken from the from _CallableType:: def __getitem__(self, params

[issue42233] GenericAlias does not support union type expressions

2020-11-01 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +21999 pull_request: https://github.com/python/cpython/pull/23081 ___ Python tracker <https://bugs.python.org/issue42

[issue42233] GenericAlias does not support union type expressions

2020-11-01 Thread Ken Jin
Ken Jin added the comment: @Serhiy, wow interesting find, it seems to be typing's repr problem rather than the actual types itself: >>> typing.Union[dict[int, str], list[str]] typing.Union[dict, list] >>> typing.Union[dict[int, str], list[str]].__args__ (dict[i

[issue42233] GenericAlias does not support union type expressions

2020-11-01 Thread Ken Jin
Change by Ken Jin : -- keywords: +patch pull_requests: +21997 stage: -> patch review pull_request: https://github.com/python/cpython/pull/23077 ___ Python tracker <https://bugs.python.org/issu

[issue42233] GenericAlias does not support union type expressions

2020-11-01 Thread Ken Jin
New submission from Ken Jin : Union type expressions added in PEP 604 throw an error when both operands are GenericAlias objects. Eg the following works:: int | list[str] The following throws TypeError:: list[int] | dict[float, str] Traceback (most recent call last): File "&quo

[issue40814] Update typing module documentation based on PEP 585

2020-10-31 Thread Ken Jin
Ken Jin added the comment: IMO, this can now be closed. Most code examples in typing were changed to builtin generics: https://github.com/python/cpython/commit/d9ab95ff1fe81efdf70e545d536d9f6927d1ba81 https://github.com/python/cpython/commit/7f54e563dc150cd670ca8df678437455c3a7f2cd Docs

[issue42198] Clean up docs for Union and GenericAlias

2020-10-31 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +21982 pull_request: https://github.com/python/cpython/pull/23063 ___ Python tracker <https://bugs.python.org/issue42

[issue42198] Clean up docs for Union and GenericAlias

2020-10-31 Thread Ken Jin
Ken Jin added the comment: Guido, I have one last one -- "2. Park GenericAlias and Union under a new section 'Type Annotation Types' in stdtypes for 3.10". After which I'll close this issue. Thanks for reviewing my PRs so quickly! --

<    1   2   3   4   5   6   >