Commit Graph

23 Commits

Author SHA1 Message Date
Florian Bruhin f2ec540a1b tests: Fix sys.flags workaround with older Python versions
types.SimpleNamespace only accepts a positional argument with Python 3.13: 'https://docs.python.org/3/whatsnew/3.13.html#types'
2025-07-29 10:10:13 +02:00
Florian Bruhin b9aec6777a tests: Fix monkeypatching of sys.flags on Python 3.14
With Python 3.14, since argparse enabled coloring by default:
17c5959aa3
running test_cmdutils.py failed with a lengthy traceback finishing in:

```
INTERNALERROR> pluggy.PluggyTeardownRaisedWarning: A plugin raised an exception during an old-style hookwrapper teardown.
INTERNALERROR> Plugin: /home/florian/proj/qutebrowser/git/tests/conftest.py, Hook: pytest_runtest_makereport
INTERNALERROR> PluggyTeardownRaisedWarning: A plugin raised an exception during an old-style hookwrapper teardown.
INTERNALERROR> Plugin: rerunfailures, Hook: pytest_runtest_makereport
INTERNALERROR> PluggyTeardownRaisedWarning: A plugin raised an exception during an old-style hookwrapper teardown.
INTERNALERROR> Plugin: hypothesispytest, Hook: pytest_runtest_makereport
INTERNALERROR> PluggyTeardownRaisedWarning: A plugin raised an exception during an old-style hookwrapper teardown.
INTERNALERROR> Plugin: pytest-bdd, Hook: pytest_runtest_makereport
INTERNALERROR> AttributeError: 'types.SimpleNamespace' object has no attribute 'verbose'
```

with one part pointing to Python internals:

```pytb
INTERNALERROR>   File "/home/florian/proj/qutebrowser/git/.tox/py314-pyqt68/lib/python3.14/site-packages/_pytest/_code/code.py", line 669, in exconly
INTERNALERROR>     lines = format_exception_only(self.type, self.value)
INTERNALERROR>   File "/usr/lib/python3.14/traceback.py", line 180, in format_exception_only
INTERNALERROR>     te = TracebackException(type(value), value, None, compact=True)
INTERNALERROR>   File "/usr/lib/python3.14/traceback.py", line 1106, in __init__
INTERNALERROR>     suggestion = _compute_suggestion_error(exc_value, exc_traceback, wrong_name)
INTERNALERROR>   File "/usr/lib/python3.14/traceback.py", line 1653, in _compute_suggestion_error
INTERNALERROR>     import _suggestions
INTERNALERROR>   File "<frozen importlib._bootstrap>", line 1371, in _find_and_load
INTERNALERROR>   File "<frozen importlib._bootstrap>", line 1342, in _find_and_load_unlocked
INTERNALERROR>   File "<frozen importlib._bootstrap>", line 951, in _load_unlocked
INTERNALERROR>   File "<frozen importlib._bootstrap>", line 496, in _verbose_message
INTERNALERROR> AttributeError: 'types.SimpleNamespace' object has no attribute 'verbose'
```

This happens when Python tries to access sys.flags.verbose, but we replaced it
with a fake object that does not have a .verbose attribute anymore (only
temporarily, but for some reason that's enough to trigger the issue anyways).

Since we can't mutate sys.flags, instead we create an object that copies all
sys.flags attributes, and then use that as a nicer replacement.

See #8529
2025-07-27 13:58:15 +02:00
Florian Bruhin 0718b25796 reuse: Initial copyright text update for myself
git ls-files | \
    xargs sed -Ei 's/Copyright [0-9]{4}(-[0-9]{4}) Florian Bruhin \(The Compiler\) <mail@qutebrowser\.org>/SPDX-FileCopyrightText: Florian Bruhin (The Compiler) <mail@qutebrowser.org>/'
2023-07-23 12:49:05 +02:00
Florian Bruhin b2aaba6043 reuse: Adjust most license headers
git ls-files | xargs grep -l "is free software"  | xargs reuse annotate --license="GPL-3.0-or-later" --skip-unrecognised
2023-07-23 12:11:07 +02:00
Philipp Albrecht d9e8b638bf Remove vim modelines
We're deprecating vim modelines in favor of `.editorconfig`.

Removing vim modelines could be done using two one-liners. Most of the vim modelines
were followed by an empty line, so this one-liner took care of these ones:

```sh
rg '^# vim: .+\n\n' -l | xargs sed -i '/^# vim: /,+1d'
```

Then some of the vim modelines were followed by a pylint configuration line, so running
this one-liner afterwards took care of that:

```sh
rg '^# vim:' -l | xargs sed -i '/^# vim: /d'
```
2023-06-30 11:03:06 +02:00
Florian Bruhin 100e87ff0e pylint: Remove now-useless suppressions 2021-12-02 17:43:45 +01:00
Florian Bruhin ac2576c61d command: Improve deprecation
Add a test and also allow setting a deprecated alias for a command
easily.
2021-01-27 15:08:41 +01:00
Florian Bruhin 61ce42fc74 Update test_typed_args for lazy annotations
This unfortunately gets quite a bit more cumbersome, as we can't easily
parametrize an annotation anymore - the former `typ` will just be lazily
evaluated as the string "typ".

Closes #5769
2021-01-26 20:32:46 +01:00
Florian Bruhin 41dc291309 Add initial support for Python 3.10 annotations
PEP 563: https://www.python.org/dev/peps/pep-0563/
See #5769
2021-01-26 20:32:31 +01:00
Florian Bruhin 1a4fff1a42 doc: Switch URLs to https 2021-01-26 15:19:01 +01:00
Florian Bruhin 222f1f19a1 Bump copyright years
Closes #6015
2021-01-20 20:06:19 +01:00
Tim Brown 0a9b85c310 mypy: use from-import for typing in remaining files
I believe this should close #5396
2020-10-31 22:52:00 +10:00
Florian Bruhin 46302e488f Use enum.auto() for most enum values
Doesn't change values where they are chosen to line up with Qt enums.

See #4800
2020-10-26 15:50:54 +01:00
Florian Bruhin 518e9497d7 Make pylint happy 2020-10-16 16:42:17 +02:00
Yegor b2dd22c5e9 Use class-based API instead of functions for enums 2020-10-09 20:04:49 +03:00
Florian Bruhin 049d51d1d7 Fix lint 2020-06-11 17:23:59 +02:00
Florian Bruhin 025a70254f commands: Add some additional tests for *args handling
(cherry picked from commit 3983a6d3ee30f86b1afd809bc786322cbff8fd55)
2020-06-11 15:49:23 +02:00
Florian Bruhin 9e4276db9b Adjust copyrights for 2020 2020-01-04 18:21:17 +01:00
Jay Kamat 3e816f5f8b
Update copyright for 2019 2019-02-22 21:45:08 -08:00
Florian Bruhin 2cb277afd7 Fix exception messages in Command
The messages weren't updated in ac78039171.
2018-12-04 16:30:01 +01:00
Florian Bruhin 71f9c5d206 Fix handling of annotated varargs in commands
When we have something like "*values: str" in :config-cycle, we get a list of
values, but the type converter assumes it's a string.

We could implement proper conversion of *args, but for now, let's just make
sure it's always a string.
2018-12-03 15:55:04 +01:00
Florian Bruhin 569bb0fa09 Add cmdutils.Value instead of using count=True/win_id=True 2018-11-30 12:45:01 +01:00
Florian Bruhin b7de287e7b Move CommandError to api.cmdutils 2018-11-29 14:18:11 +01:00