Skip to content

Commit 1006446

Browse files
generatedunixname1386863909833763meta-codesync[bot]
authored andcommitted
fbcode/cinderx/PythonLib/cinderx/compiler/pycodegen.py
Summary: Remove 5 `pyre-fixme` suppressions in `pycodegen.py` by fixing the underlying type issues: **`emitAugName` (1 fixme removed):** Added `assert isinstance(target, ast.Name)` to narrow the type of `node.target` from `ast.expr` to `ast.Name`. The caller `visitAugAssign` already guarantees this via an `isinstance` check before dispatching, so this makes the existing assumption explicit for Pyre. **`emit_try_star_except` (4 fixmes removed):** Bound `handler.name` (typed `str | None`) to a local variable `handler_name` before the existing `if handler_name:` checks. Pyre was losing the `Optional` narrowing across interleaving method calls (`self.emit`, `self.storeName`). The local variable preserves the narrowing without changing control flow. --- > Generated by [RACER](https://www.internalfb.com/wiki/RACER_(Risk-Aware_Code_Editing_and_Refactoring)/), powered by [Confucius](https://www.internalfb.com/wiki/Confucius/Analect/Shared_Analects/Confucius_Code_Assist_(CCA)/) [Session](https://www.internalfb.com/confucius?session_id=32fb3408-21bd-11f1-b9cb-85e1b7b3e743&tab=Chat), [Trace](https://www.internalfb.com/confucius?session_id=32fb3408-21bd-11f1-b9cb-85e1b7b3e743&tab=Trace) Reviewed By: alexmalyshev, yoney Differential Revision: D96873199 fbshipit-source-id: 3d606bc572d8609819242f9d74bd49acb5842e94
1 parent 216d49b commit 1006446

1 file changed

Lines changed: 8 additions & 17 deletions

File tree

cinderx/PythonLib/cinderx/compiler/pycodegen.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,9 +1414,7 @@ def emitAugRHS(self, node: ast.AugAssign) -> None:
14141414

14151415
def emitAugName(self, node: ast.AugAssign) -> None:
14161416
target = node.target
1417-
1418-
# pyre-fixme[16] This code assumes that the target of the AugAssign is a
1419-
# Name as opposed to ast.Attribute or ast.Subscript.
1417+
assert isinstance(target, ast.Name)
14201418
name = target.id
14211419

14221420
self.loadName(name)
@@ -5446,26 +5444,19 @@ def emit_try_star_except(self, node: ast.TryStar) -> None:
54465444
self.pop_fblock(HANDLER_CLEANUP)
54475445
self.set_no_pos()
54485446
self.emit("POP_BLOCK")
5449-
if handler.name:
5447+
handler_name = handler.name
5448+
if handler_name:
54505449
self.emit("LOAD_CONST", None)
5451-
# pyre-fixme[6]: For 1st argument expected `str` but got
5452-
# `Optional[str]`.
5453-
self.storeName(handler.name)
5454-
# pyre-fixme[6]: For 1st argument expected `str` but got
5455-
# `Optional[str]`.
5456-
self.delName(handler.name)
5450+
self.storeName(handler_name)
5451+
self.delName(handler_name)
54575452
self.emit_jump_forward(except_)
54585453

54595454
# except:
54605455
self.nextBlock(cleanup_end)
5461-
if handler.name:
5456+
if handler_name:
54625457
self.emit("LOAD_CONST", None)
5463-
# pyre-fixme[6]: For 1st argument expected `str` but got
5464-
# `Optional[str]`.
5465-
self.storeName(handler.name)
5466-
# pyre-fixme[6]: For 1st argument expected `str` but got
5467-
# `Optional[str]`.
5468-
self.delName(handler.name)
5458+
self.storeName(handler_name)
5459+
self.delName(handler_name)
54695460

54705461
# add exception raised to the res list
54715462
self.emit("LIST_APPEND", 3)

0 commit comments

Comments
 (0)