From 5fa878c7d190ba227aa05ab01385e640fc7ff42b Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 26 Jun 2023 14:31:55 +0200 Subject: 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) --- qutebrowser/browser/webkit/network/networkreply.py | 4 ++-- qutebrowser/config/stylesheet.py | 2 +- qutebrowser/config/websettings.py | 2 +- qutebrowser/utils/jinja.py | 2 +- tests/end2end/conftest.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/qutebrowser/browser/webkit/network/networkreply.py b/qutebrowser/browser/webkit/network/networkreply.py index 4fb7dfea5..4c8e698ba 100644 --- a/qutebrowser/browser/webkit/network/networkreply.py +++ b/qutebrowser/browser/webkit/network/networkreply.py @@ -128,7 +128,7 @@ class ErrorNetworkReply(QNetworkReply): def readData(self, _maxlen): """No data available.""" - return bytes() + return b'' def isFinished(self): return True @@ -150,4 +150,4 @@ class RedirectNetworkReply(QNetworkReply): """Called when there's e.g. a redirection limit.""" def readData(self, _maxlen): - return bytes() + return b'' diff --git a/qutebrowser/config/stylesheet.py b/qutebrowser/config/stylesheet.py index 8ad873ab5..c840a99c2 100644 --- a/qutebrowser/config/stylesheet.py +++ b/qutebrowser/config/stylesheet.py @@ -48,7 +48,7 @@ def set_register(obj: QWidget, @debugcachestats.register() -@functools.lru_cache() +@functools.lru_cache def _render_stylesheet(stylesheet: str) -> str: """Render the given stylesheet jinja template.""" with jinja.environment.no_autoescape(): diff --git a/qutebrowser/config/websettings.py b/qutebrowser/config/websettings.py index 7f59367cb..e5dd2e037 100644 --- a/qutebrowser/config/websettings.py +++ b/qutebrowser/config/websettings.py @@ -203,7 +203,7 @@ class AbstractSettings: @debugcachestats.register(name='user agent cache') -@functools.lru_cache() +@functools.lru_cache def _format_user_agent(template: str, backend: usertypes.Backend) -> str: if backend == usertypes.Backend.QtWebEngine: from qutebrowser.browser.webengine import webenginesettings diff --git a/qutebrowser/utils/jinja.py b/qutebrowser/utils/jinja.py index 5775b317b..da8878aee 100644 --- a/qutebrowser/utils/jinja.py +++ b/qutebrowser/utils/jinja.py @@ -142,7 +142,7 @@ js_environment = jinja2.Environment(loader=Loader('javascript')) @debugcachestats.register() -@functools.lru_cache() +@functools.lru_cache def template_config_variables(template: str) -> FrozenSet[str]: """Return the config variables used in the template.""" unvisted_nodes: List[jinja2.nodes.Node] = [environment.parse(template)] diff --git a/tests/end2end/conftest.py b/tests/end2end/conftest.py index bdc172857..febe1b70b 100644 --- a/tests/end2end/conftest.py +++ b/tests/end2end/conftest.py @@ -69,7 +69,7 @@ def _check_version(op_str, running_version, version_str, as_hex=False): '<': operator.lt, } 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: version = (major << 16) | (minor << 8) | patch else: -- cgit v1.2.3-54-g00ecf