44import os
55import subprocess
66from collections import OrderedDict
7- from typing import Optional
87
98from ._metadata import APP
109
@@ -146,7 +145,7 @@ def find_remote_branches_at(self, remote_name) -> list[str]:
146145 extra_argv = ["--remote" , "--list" , f"{ remote_name } /*" ]
147146 return self ._find_branches (extra_argv )
148147
149- def find_current_branch (self ) -> Optional [ str ] :
148+ def find_current_branch (self ) -> str | None :
150149 # Note: Avoiding "git branch --show-current" of Git >=2.22.0
151150 # to keep Git 2.17.1 of Ubuntu 18.04 in the boat, for now.
152151 argv = [self ._GIT , "rev-parse" , "--symbolic-full-name" , "HEAD" ]
@@ -160,15 +159,15 @@ def find_current_branch(self) -> Optional[str]:
160159 return None # detached head
161160 return reference [len (expected_prefix ) :]
162161
163- def find_working_tree_branches (self ) -> list [Optional [ str ] ]:
162+ def find_working_tree_branches (self ) -> list [str | None ]:
164163 argv = [self ._GIT , "worktree" , "list" , "--porcelain" ] # requires Git >=2.7.0
165164 output_bytes = self ._subprocess_check_output (argv , is_write = False )
166165 lines = self ._output_bytes_to_lines (output_bytes )
167166
168167 detached_line_prefix = "detached"
169168 branch_line_prefix = "branch "
170169 branch_prefix = "refs/heads/"
171- branch_names : list [Optional [ str ] ] = []
170+ branch_names : list [str | None ] = []
172171
173172 for line in lines :
174173 if line .startswith (detached_line_prefix ):
@@ -266,7 +265,7 @@ def pull_ff_only(self) -> None:
266265 raise PullFailed
267266 raise
268267
269- def _has_changes (self , extra_argv : Optional [ list [str ]] = None ) -> bool :
268+ def _has_changes (self , extra_argv : list [str ] | None = None ) -> bool :
270269 argv = [self ._GIT , "diff" , "--exit-code" , "--quiet" ]
271270 if extra_argv :
272271 argv += extra_argv
0 commit comments