FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

rewrite: minor improvements for frame.py. · ag-python/pytype@436cd65 · GitHub

forked from google/pytype

Commit 436cd65

Browse files
committed
rewrite: minor improvements for frame.py.
* Use Variable.has_atomic_value() instead of get_atomic_value() with try/except * Add test coverage for the LIST_EXTEND opcode PiperOrigin-RevId: 623996578
1 parent 61404c4 commit 436cd65

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

‎pytype/rewrite/frame.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -537,12 +537,10 @@ def byte_IMPORT_NAME(self, opcode):
537537
# The IMPORT_NAME for an "import a.b.c" will push the module "a".
538538
# However, for "from a.b.c import Foo" it'll push the module "a.b.c". Those
539539
# two cases are distinguished by whether fromlist is None or not.
540-
try:
541-
abstract.get_atomic_constant(fromlist, None)
542-
except ValueError:
543-
module_name = full_name
544-
else:
540+
if fromlist.has_atomic_value(self._ctx.consts[None]):
545541
module_name = full_name.split('.', 1)[0] # "a.b.c" -> "a"
542+
else:
543+
module_name = full_name
546544
module = abstract.Module(self._ctx, module_name)
547545
return self._stack.push(module.to_variable())
548546

‎pytype/rewrite/tests/test_basic.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ def f(x, *, y):
4747
f(0, y=1)
4848
""")
4949

50+
def test_function_varargs(self):
51+
self.Check("""
52+
def foo(x: str, *args):
53+
pass
54+
def bar(*args):
55+
foo('abc', *args)
56+
""")
57+
5058
def test_class(self):
5159
self.Check("""
5260
class C:

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL