mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	gh-104273: Remove redundant len() calls in argparse function (#104274)
This commit is contained in:
		
							parent
							
								
									ac020624b3
								
							
						
					
					
						commit
						01cc9c1ff7
					
				
					 1 changed files with 4 additions and 3 deletions
				
			
		| 
						 | 
					@ -345,21 +345,22 @@ def _format_usage(self, usage, actions, groups, prefix):
 | 
				
			||||||
                def get_lines(parts, indent, prefix=None):
 | 
					                def get_lines(parts, indent, prefix=None):
 | 
				
			||||||
                    lines = []
 | 
					                    lines = []
 | 
				
			||||||
                    line = []
 | 
					                    line = []
 | 
				
			||||||
 | 
					                    indent_length = len(indent)
 | 
				
			||||||
                    if prefix is not None:
 | 
					                    if prefix is not None:
 | 
				
			||||||
                        line_len = len(prefix) - 1
 | 
					                        line_len = len(prefix) - 1
 | 
				
			||||||
                    else:
 | 
					                    else:
 | 
				
			||||||
                        line_len = len(indent) - 1
 | 
					                        line_len = indent_length - 1
 | 
				
			||||||
                    for part in parts:
 | 
					                    for part in parts:
 | 
				
			||||||
                        if line_len + 1 + len(part) > text_width and line:
 | 
					                        if line_len + 1 + len(part) > text_width and line:
 | 
				
			||||||
                            lines.append(indent + ' '.join(line))
 | 
					                            lines.append(indent + ' '.join(line))
 | 
				
			||||||
                            line = []
 | 
					                            line = []
 | 
				
			||||||
                            line_len = len(indent) - 1
 | 
					                            line_len = indent_length - 1
 | 
				
			||||||
                        line.append(part)
 | 
					                        line.append(part)
 | 
				
			||||||
                        line_len += len(part) + 1
 | 
					                        line_len += len(part) + 1
 | 
				
			||||||
                    if line:
 | 
					                    if line:
 | 
				
			||||||
                        lines.append(indent + ' '.join(line))
 | 
					                        lines.append(indent + ' '.join(line))
 | 
				
			||||||
                    if prefix is not None:
 | 
					                    if prefix is not None:
 | 
				
			||||||
                        lines[0] = lines[0][len(indent):]
 | 
					                        lines[0] = lines[0][indent_length:]
 | 
				
			||||||
                    return lines
 | 
					                    return lines
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                # if prog is short, follow it with optionals or positionals
 | 
					                # if prog is short, follow it with optionals or positionals
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue