py38: Run modified pyupgrade

Modified to leave f-strings alone for now, and also not do some other
stuff we should do separately:

    diff --git i/pyupgrade/_main.py w/pyupgrade/_main.py
    index 4292174..37547b3 100644
    --- i/pyupgrade/_main.py
    +++ w/pyupgrade/_main.py
    @@ -294,7 +294,8 @@ def _fix_tokens(contents_text: str) -> str:
                    token.utf8_byte_offset == 0 and
                    token.line < 3 and
                    token.name == 'COMMENT' and
    -                tokenize.cookie_re.match(token.src)
    +                tokenize.cookie_re.match(token.src) and
    +                False
            ):
                del tokens[i]
                assert tokens[i].name == 'NL', tokens[i].name
    diff --git i/pyupgrade/_plugins/fstrings.py w/pyupgrade/_plugins/fstrings.py
    index e648075..eb44c0c 100644
    --- i/pyupgrade/_plugins/fstrings.py
    +++ w/pyupgrade/_plugins/fstrings.py
    @@ -88,7 +88,7 @@ def _format_params(call: ast.Call) -> set[str]:
        return params

    -@register(ast.Call)
    +# @register(ast.Call)
    def visit_Call(
            state: State,
            node: ast.Call,
    diff --git i/pyupgrade/_plugins/open_mode.py w/pyupgrade/_plugins/open_mode.py
    index a20b95c..0388781 100644
    --- i/pyupgrade/_plugins/open_mode.py
    +++ w/pyupgrade/_plugins/open_mode.py
    @@ -28,7 +28,7 @@ def _permute(*args: str) -> tuple[str, ...]:
        return tuple(''.join(p) for s in args for p in itertools.permutations(s))

    -MODE_REMOVE = frozenset(_permute('U', 'r', 'rU', 'rt'))
    +MODE_REMOVE = frozenset(_permute('U', 'rU', 'rt'))
    MODE_REPLACE_R = frozenset(_permute('Ub'))
    MODE_REMOVE_T = frozenset(_plus(_permute('at', 'rt', 'wt', 'xt')))
    MODE_REMOVE_U = frozenset(_permute('rUb'))

Then run with:

    git ls-files | grep -E '(\.py|misc/userscripts)' | xargs ~/tmp/pyupgrade/.venv/bin/pyupgrade --py38-plus

And manually reverted some changes (e.g. it picking up bash userscripts)
This commit is contained in:
Florian Bruhin 2023-06-26 14:31:55 +02:00
parent 93c7fdd60c
commit 5fa878c7d1
5 changed files with 6 additions and 6 deletions

View File

@ -128,7 +128,7 @@ class ErrorNetworkReply(QNetworkReply):
def readData(self, _maxlen): def readData(self, _maxlen):
"""No data available.""" """No data available."""
return bytes() return b''
def isFinished(self): def isFinished(self):
return True return True
@ -150,4 +150,4 @@ class RedirectNetworkReply(QNetworkReply):
"""Called when there's e.g. a redirection limit.""" """Called when there's e.g. a redirection limit."""
def readData(self, _maxlen): def readData(self, _maxlen):
return bytes() return b''

View File

@ -48,7 +48,7 @@ def set_register(obj: QWidget,
@debugcachestats.register() @debugcachestats.register()
@functools.lru_cache() @functools.lru_cache
def _render_stylesheet(stylesheet: str) -> str: def _render_stylesheet(stylesheet: str) -> str:
"""Render the given stylesheet jinja template.""" """Render the given stylesheet jinja template."""
with jinja.environment.no_autoescape(): with jinja.environment.no_autoescape():

View File

@ -203,7 +203,7 @@ class AbstractSettings:
@debugcachestats.register(name='user agent cache') @debugcachestats.register(name='user agent cache')
@functools.lru_cache() @functools.lru_cache
def _format_user_agent(template: str, backend: usertypes.Backend) -> str: def _format_user_agent(template: str, backend: usertypes.Backend) -> str:
if backend == usertypes.Backend.QtWebEngine: if backend == usertypes.Backend.QtWebEngine:
from qutebrowser.browser.webengine import webenginesettings from qutebrowser.browser.webengine import webenginesettings

View File

@ -142,7 +142,7 @@ js_environment = jinja2.Environment(loader=Loader('javascript'))
@debugcachestats.register() @debugcachestats.register()
@functools.lru_cache() @functools.lru_cache
def template_config_variables(template: str) -> FrozenSet[str]: def template_config_variables(template: str) -> FrozenSet[str]:
"""Return the config variables used in the template.""" """Return the config variables used in the template."""
unvisted_nodes: List[jinja2.nodes.Node] = [environment.parse(template)] unvisted_nodes: List[jinja2.nodes.Node] = [environment.parse(template)]

View File

@ -69,7 +69,7 @@ def _check_version(op_str, running_version, version_str, as_hex=False):
'<': operator.lt, '<': operator.lt,
} }
op = operators[op_str] op = operators[op_str]
major, minor, patch = [int(e) for e in version_str.split('.')] major, minor, patch = (int(e) for e in version_str.split('.'))
if as_hex: if as_hex:
version = (major << 16) | (minor << 8) | patch version = (major << 16) | (minor << 8) | patch
else: else: