[issue41515] typing.get_type_hints generates KeyError

2021-06-23 Thread Will Chen


Change by Will Chen :


--
nosy: +WCA
nosy_count: 6.0 -> 7.0
pull_requests: +25458
pull_request: https://github.com/python/cpython/pull/26862

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41515] typing.get_type_hints generates KeyError

2021-04-13 Thread STINNER Victor


STINNER Victor  added the comment:

I see that all PRs are merged, and the CI issue is fixed as well. I close the 
issue.

commit eb77133564d74eb09ed63872a69b9827d4841b49
Author: Karthikeyan Singaravelan 
Date:   Tue Apr 13 19:24:23 2021 +0530

bpo41515: Fix assert in test which throws SyntaxWarning. (#25379)

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41515] typing.get_type_hints generates KeyError

2021-04-12 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Thanks Victor. I have created https://github.com/python/cpython/pull/25379 that 
uses self.assertEqual instead of assert that produces syntax warning.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41515] typing.get_type_hints generates KeyError

2021-04-12 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
pull_requests: +24111
pull_request: https://github.com/python/cpython/pull/25379

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41515] typing.get_type_hints generates KeyError

2021-04-12 Thread STINNER Victor


STINNER Victor  added the comment:

> Thanks -- odd this didn't fail in CI.

The CI runs tests with "make buildbottest" which uses the -w option:

  -w, --verbose2re-run failed tests in verbose mode

When test___all__ is re-run in verbose mode, it doesn't fail:

"== Tests result: FAILURE then SUCCESS =="

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41515] typing.get_type_hints generates KeyError

2021-04-12 Thread Guido van Rossum


Guido van Rossum  added the comment:

Thanks -- odd this didn't fail in CI. We'll get it fixed.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41515] typing.get_type_hints generates KeyError

2021-04-12 Thread STINNER Victor


STINNER Victor  added the comment:

This change introduced a regression:
https://buildbot.python.org/all/#/builders/96/builds/1012

$ ./python -m test test___all__
0:00:00 load avg: 0.28 Run tests sequentially
0:00:00 load avg: 0.28 [1/1] test___all__
test test___all__ failed -- Traceback (most recent call last):
  File "/home/vstinner/python/master/Lib/test/test___all__.py", line 104, in 
test_all
self.check_all(modname)
  File "/home/vstinner/python/master/Lib/test/test___all__.py", line 25, in 
check_all
exec("import %s" % modname, names)
  File "/home/vstinner/python/master/Lib/contextlib.py", line 140, in __exit__
next(self.gen)
  File "/home/vstinner/python/master/Lib/test/support/warnings_helper.py", line 
177, in _filterwarnings
raise AssertionError("unhandled warning %s" % reraise[0])
AssertionError: unhandled warning {message : SyntaxWarning('assertion is always 
true, perhaps remove parentheses?'), category : 'SyntaxWarning', filename : 
'/home/vstinner/python/master/Lib/test/test_typing.py', lineno : 2275, line : 
None}

test___all__ failed

== Tests result: FAILURE ==

1 test failed:
test___all__

Total duration: 2.7 sec
Tests result: FAILURE


It comes from the following line of test_bad_module() in Lib/test/test_typing:

assert(get_type_hints(BadModule), {})

assert should be used as "assert test" or "assert test, expr". assert (expr, 
expr) tests if the tuple (2 items) is true, and it's always true.

--
nosy: +vstinner

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41515] typing.get_type_hints generates KeyError

2021-04-12 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset a9cf69df2e031d6157f01289f66ca9cf723ceb5c by Karthikeyan 
Singaravelan in branch 'master':
bpo-41515: Fix KeyError raised in get_type_hints (GH-25352)
https://github.com/python/cpython/commit/a9cf69df2e031d6157f01289f66ca9cf723ceb5c


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41515] typing.get_type_hints generates KeyError

2021-04-12 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
pull_requests: +24087
pull_request: https://github.com/python/cpython/pull/25352

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41515] typing.get_type_hints generates KeyError

2021-04-11 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

I guess more libraries will experience this with `from __future__ import 
annotations` becoming default in Python 3.10 and they switch to get_type_hints.

https://github.com/sphinx-doc/sphinx/issues/8084
https://github.com/facebook/TestSlide/issues/296

--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41515] typing.get_type_hints generates KeyError

2020-08-10 Thread Roundup Robot


Change by Roundup Robot :


--
keywords: +patch
nosy: +python-dev
nosy_count: 3.0 -> 4.0
pull_requests: +20948
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/21816

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41515] typing.get_type_hints generates KeyError

2020-08-10 Thread Guido van Rossum


Guido van Rossum  added the comment:

Hm, the fix would seem simple enough. Can you submit a PR? It would be nice if 
it had a test as well.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41515] typing.get_type_hints generates KeyError

2020-08-10 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +gvanrossum, levkivskyi

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41515] typing.get_type_hints generates KeyError

2020-08-10 Thread Eric Fahlgren


New submission from Eric Fahlgren :

Windows 10 Pro 64
Python 3.8.3 64
wxPython 4.1.0

It appears that there are synthetic classes in the mro, which don't appear in 
the type's namespace, raising KeyError when encountered.  From reading the 
function's doc and source, it looks like it should handle this internally and 
return a valid dict (possibly empty), and not raise KeyError.

>>> import typing, wx
>>> typing.get_type_hints(wx.Window)'
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Program Files\Python38\lib\typing.py", line 1223, in get_type_hints
base_globals = sys.modules[base.__module__].__dict__

>>> wx.Window.mro()
[, , , , , , , 
]

KeyError: 'sip'

--
components: Library (Lib)
messages: 375111
nosy: eric.fahlgren
priority: normal
severity: normal
status: open
title: typing.get_type_hints generates KeyError
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com