Accept suggestions from new toolchain · rec/pullman@96265e3

@@ -6,17 +6,17 @@

66

import os

77

import re

88

import stat

9-

import subprocess

109

import sys

10+

import time

1111

import webbrowser

1212

from argparse import Namespace

13+

from collections.abc import Sequence

1314

from contextlib import nullcontext, suppress

1415

from functools import cache, cached_property

1516

from operator import attrgetter

1617

from pathlib import Path

1718

from subprocess import CalledProcessError, run

18-

from typing import Any, Optional, Sequence

19-19+

from typing import Any, Optional

20202121

try:

2222

import bs4

@@ -174,7 +174,7 @@ def _get_ghstack_message(ref: str) -> tuple[str, list[str]]:

174174175175

@dc.dataclass

176176

class PullRequests:

177-

argv: Optional[Sequence[str]] = None

177+

argv: Sequence[str] | None = None

178178

path: Path = DEFAULT_CACHE_PATH

179179180180

def load(self) -> None:

@@ -225,7 +225,7 @@ def __call__(self) -> None:

225225

or ()

226226

)

227227

msg = e.args[0]

228-

if arg and not arg in msg:

228+

if arg and arg not in msg:

229229

msg = f'{msg} for {arg}'

230230

error(msg)

231231

@@ -239,7 +239,7 @@ def _checkout(self):

239239

error(f'At most one of {set_flags} can be set')

240240241241

_run(f'ghstack checkout {self._matching_pull().url}')

242-

if rebase := (

242+

if (

243243

self.args.rebase_against

244244

or (self.args.rebase_main and 'upstream/main')

245245

or (self.args.rebase_strict and 'upstream/viable/strict')

@@ -265,7 +265,6 @@ def clean_and_sort(user: str) -> list[PullRequest]:

265265

pulls = []

266266

for p in self.pulls.get(user, ()):

267267

with suppress(PullError):

268-

p.pull_number

269268

if search in p.subject and (self.args.closed or p.is_open):

270269

pulls.append(p)

271270

@@ -339,6 +338,7 @@ def _errors(self) -> None:

339338340339

if self.args.python or (self.args.python_default and sys.executable):

341340

if not os.path.isdir(self.args.python):

341+

# TODO!

342342

python = os.path.dirname(self.args.python)

343343

print(f'export PATH={self.args.python}:$PATH\n', file=file)

344344

run_error_command(pull.pull_number, self.args, file)

@@ -375,7 +375,7 @@ def remotes(self):

375375

@cached_property

376376

def user(self) -> str:

377377

if user := getattr(self.args, 'user', None):

378-

return self.args.user

378+

return user

379379

if len(self.remotes) != 1:

380380

return self.remotes['origin']

381381

for r in self.remotes.values():

@@ -426,7 +426,7 @@ class ArgumentParser(argparse.ArgumentParser):

426426427427

_epilog: str = HELP

428428429-

def exit(self, status: int = 0, message: Optional[str] = None):

429+

def exit(self, status: int = 0, message: str | None = None):

430430

"""

431431

Overriding this method is a workaround for argparse throwing away all

432432

line breaks when printing the `epilog` section of the help message.