File tree Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -8168,7 +8168,7 @@ def deconstruct_keys(keys)
81688168 # not value
81698169 #
81708170 class Not < Node
8171- # [untyped] the statement on which to operate
8171+ # [nil | untyped] the statement on which to operate
81728172 attr_reader :statement
81738173
81748174 # [boolean] whether or not parentheses were used
@@ -8205,7 +8205,7 @@ def deconstruct_keys(keys)
82058205
82068206 def format ( q )
82078207 q . text ( parentheses ? "not(" : "not " )
8208- q . format ( statement )
8208+ q . format ( statement ) if statement
82098209 q . text ( ")" ) if parentheses
82108210 end
82118211 end
Original file line number Diff line number Diff line change @@ -2837,19 +2837,17 @@ def on_unary(operator, statement)
28372837 # parentheses they don't get reported as a paren node for some reason.
28382838
28392839 beginning = find_token ( Kw , "not" )
2840- ending = statement
2840+ ending = statement || beginning
2841+ parentheses = source [ beginning . location . end_char ] == "("
28412842
2842- range = beginning . location . end_char ...statement . location . start_char
2843- paren = source [ range ] . include? ( "(" )
2844-
2845- if paren
2843+ if parentheses
28462844 find_token ( LParen )
28472845 ending = find_token ( RParen )
28482846 end
28492847
28502848 Not . new (
28512849 statement : statement ,
2852- parentheses : paren ,
2850+ parentheses : parentheses ,
28532851 location : beginning . location . to ( ending . location )
28542852 )
28552853 else
Original file line number Diff line number Diff line change 11%
2+ not()
3+ %
4+ not ()
5+ %
26not foo
37%
48not(foo)
9+ %
10+ not (foo)
You can’t perform that action at this time.
0 commit comments