Commit graph

56 commits

Author SHA1 Message Date
Damien Elmes
631c345ef0 switch to new-style PyQt scoped enums and Qt6
The enum changes should work on PyQt 5.x, and are required in PyQt 6.x.
They are not supported by the PyQt5 typings however, so we need to run
our tests with PyQt6.
2021-10-15 12:57:19 +10:00
Damien Elmes
7dc33ad4fe generate pyqt6 forms 2021-10-15 12:57:19 +10:00
Damien Elmes
32cf761e7b expose pyqt6 packages - not yet used 2021-10-15 10:47:53 +10:00
Damien Elmes
fb6e1a73f5 bump minimum Python to 3.9 2021-10-04 15:05:15 +10:00
Damien Elmes
5e41eb7565 add a helper so we can get semi-automatic camelCase conversion 2021-06-26 11:33:35 +10:00
Damien Elmes
a8af070f9a update find&replace, and remove perform_op() 2021-04-06 17:07:38 +10:00
Damien Elmes
1c0f7274f4 enable type checking of aqt/forms, and fix the new typing issues
Referencing an invalid translation should now break the build
2021-03-26 16:06:02 +10:00
Damien Elmes
0e925b407d speed up tag drag&drop and finish tag tidyup
approx 4x speedup when reparenting 10-15 tags and their children at once
2021-03-19 19:45:21 +10:00
Damien Elmes
83a9c22186 change bulk_update() into find_and_replace_tag()
Now behaves the same way as standard find&replace:
- Will match substrings
- Regexs can be used to match multiple items; we no longer split
input on spaces.
- The find&replace dialog has been updated to add tags to the field
list.
2021-03-19 19:45:21 +10:00
Damien Elmes
42e20461c0 undoable ops now return changes directly; add new *_ops.py files
- Introduced a new transact() method that wraps the return value
in a separate struct that describes the changes that were made.
- Changes are now gathered from the undo log, so we don't need to
guess at what was changed - eg if update_note() is called with identical
note contents, no changes are returned. Card changes will only be set
if cards were actually generated by the update_note() call, and tag
will only be set if a new tag was added.
- mw.perform_op() has been updated to expect the op to return the changes,
or a structure with the changes in it, and it will use them to fire the
change hook, instead of fetching the changes from undo_status(), so there
is no risk of race conditions.
- the various calls to mw.perform_op() have been split into separate
files like card_ops.py. Aside from making the code cleaner, this works
around a rather annoying issue with mypy. Because we run it with
no_strict_optional, mypy is happy to accept an operation that returns None,
despite the type signature saying it requires changes to be returned.
Turning no_strict_optional on for the whole codebase is not practical
at the moment, but we can enable it for individual files.

Still todo:
- The cursor keeps moving back to the start of a field when typing -
we need to ignore the refresh hook when we are the initiator.
- The busy cursor icon should probably be delayed a few hundreds ms.
- Still need to think about a nicer way of handling saveNow()
- op_made_changes(), op_affects_study_queue() might be better embedded
as properties in the object instead
2021-03-19 19:45:21 +10:00
Damien Elmes
6c60a27c8b add remaining types and disable missing types on (almost) all aqt 2021-02-03 00:00:29 +10:00
RumovZ
03ed76020f Disallow untyped defs for dyndeckconf 2021-02-02 09:40:05 +01:00
Damien Elmes
8dc5ea8bb6 add types to utils.py
The function signatures for things like getFile() are awful, but
sadly are used by a bunch of add-ons.
2021-02-01 20:23:48 +10:00
Damien Elmes
34935bf478 add types to editor.py 2021-02-01 17:28:35 +10:00
Damien Elmes
fe0d6b3a10 add missing types to sidebar.py 2021-02-01 09:51:46 +10:00
Damien Elmes
2070847868 add missing types to browser.py 2021-02-01 09:39:55 +10:00
Damien Elmes
1aba818ccd add back pyaudio as an optional alternative 2020-12-18 16:52:00 +10:00
Damien Elmes
9f3659a1d3 use QtMultimedia for recording instead of PyAudio
The unmute-on-first-duration-change approach is to try to prevent
clicks/pops that can happen at the start of recordings. If it doesn't
solve the problem, we may need to drop down to the lower-level
QAudioInput().

Closes https://github.com/ankitects/help-wanted/issues/23

May fix https://forums.ankiweb.net/t/anki-crashes-periodically-after-clicking-record-audio-button/5824,
which I suspect was caused by processEvents()
2020-12-16 19:33:25 +10:00
Damien Elmes
0cb2b3f0c1 update qt/ to 3.8 as well 2020-11-11 21:37:36 +10:00
Damien Elmes
a7f403f0b0 rspy -> pylib/rsbridge 2020-11-02 15:21:12 +10:00
Damien Elmes
ce3b08ac58 initial Bazel conversion
Running and testing should be working on the three platforms, but
there's still a fair bit that needs to be done:

- Wheel building + testing in a venv still needs to be implemented.
- Python requirements still need to be compiled with piptool and pinned;
need to compile on all platforms then merge
- Cargo deps in cargo/ and rslib/ need to be cleaned up, and ideally
unified into one place
- Currently using rustls to work around openssl compilation issues
on Linux, but this will break corporate proxies with custom SSL
authorities; need to conditionally use openssl or use
https://github.com/seanmonstar/reqwest/pull/1058
- Makefiles and docs still need cleaning up
- It may make sense to reparent ts/* to the top level, as we don't
nest the other modules under a specific language.
- rspy and pylib must always be updated in lock-step, so merging
rspy into pylib as a private module would simplify things.
- Merging desktop-ftl and mobile-ftl into the core ftl would make
managing and updating translations easier.
- Obsolete scripts need removing.
- And probably more.
2020-11-01 14:26:58 +10:00
Damien Elmes
02c7a0e339 enable strict equality checks in mypy
Without it, the following code reports no problems:

def foo() -> int:
    return 5
print(foo == 5)
2020-08-03 10:26:40 +10:00
Damien Elmes
c14dc3ec38 check_untyped_defs can now be enabled globally for aqt
A big thanks to Matt and phwoo who put in most of the work to get
to this point.
2020-08-02 10:29:25 +10:00
Matt Krump
85ca0eff78 Turn on check_untyped_defs for aqt.progress 2020-07-31 21:00:08 -06:00
Matt Krump
411accc165 Turn on check_untyped_defs for aqt.main 2020-07-31 20:34:14 -06:00
Damien Elmes
d4d73a4a59 Merge branch 'master' into help-wanted-4-add-type-hints-6 2020-07-31 14:07:59 +10:00
Matt Krump
eef069f2b7 Turn on check_untyped_defs for aqt.emptycards 2020-07-30 18:43:57 -06:00
Matt Krump
1fe46438c0 Turn on check_untyped_defs for aqt.addons 2020-07-30 18:43:57 -06:00
Matt Krump
8feb2acbbf Turn on check_untyped_defs for aqt.webview 2020-07-30 18:43:57 -06:00
Fabian Wood
4a7558f9be Added typehints for qt profiles
* `Any` used for pickle methods, this could probably be improved
with some kind of Callable
* str used for self.base, though this may be a problem for
different OSes. Some type of os.PathLike might be good.
* Line 75, type ignored: mypy was complaining about no. of args,
and kwargs there didn't seem to be needed. Separate issue to test,
though.
2020-07-31 00:56:48 +10:00
Fabian Wood
b23129c3eb added typehints to modelchooser, updated mypy.ini 2020-07-30 15:25:25 +10:00
Matt Krump
d4511e3287 Turn on check_untyped_defs for aqt.exporting 2020-07-28 18:42:22 -06:00
Matt Krump
98d8e1c926 Turn on check_untyped_defs for aqt.editor
* Turn on check_untyped_defs for aqt.browser
* Add type hints
2020-07-28 18:42:22 -06:00
Matt Krump
f27d465d69 Turn on check_untyped_defs for aqt.browser
* Turn on check_untyped_defs for aqt.browser
* Add type hints to browser
2020-07-25 17:31:49 -06:00
Matt Krump
a389e3ca94 Turn on check_untyped_defs for aqt.update
* Turn on check_untyped_defs for aqt.update
2020-07-25 17:31:44 -06:00
Matt Krump
8d988d2b6f Turn on check_untyped_defs for aqt.taglimit
* Add type hints taglimit
* Turn on check_untyped_defs for aqt.taglimit
2020-07-25 15:45:31 -06:00
Damien Elmes
6ad544cf62 Merge branch 'master' into help-wanted-4-add-type-hints-3 2020-07-25 11:43:46 +10:00
Matt Krump
e93ae88cdf Add type hints to importing
* Add type hints to importing
* Turn on type checking for aqt.importing
2020-07-24 12:38:34 -06:00
Matt Krump
38651d6a4e Add type hints to errors
* Add type hints to errors
* Turn on type checking for aqt.errors
2020-07-24 11:20:54 -06:00
Matt Krump
a88f935a8c Add type hints to aqt.models
* Add type hints to aqt.models
* Turn on type checking for aqt.models
2020-07-24 10:59:45 -06:00
Matt Krump
90457e5f20 Add type hints for apt.deckconf
* Add type hints for apt.deckconf
* Turn on check_untyped_defs for apt.deckconf
2020-07-23 21:53:12 -06:00
Matt Krump
51e50c176b Add type hints for apt.dyndeckconf
* Add type hints for apt.dyndeckconf
* Turn on check_untyped_defs for apt.dyndeckconf
2020-07-23 16:04:46 -06:00
BlueGreenMagick
c824d45b2e add typehint to deckchooser.py
every occurunce of self.widget is type ignored
because QHBoxLayout has a method named widget
renaming this property will allow type hints
2020-06-11 14:19:36 +09:00
Damien Elmes
c60229779c switch to new deck tree in deck browser
Saves us having to look up collapsed/filtered as we render, and gives
us type completion.
2020-05-16 10:52:14 +10:00
Damien Elmes
21ac2c14a7 handle scheduling preferences in the backend 2020-05-12 21:13:34 +10:00
Damien Elmes
b757d3db65 check untyped in clayout 2020-05-12 21:13:34 +10:00
Damien Elmes
2641862b56 update fields and models diags
- field changes are now applied when user closes dialog with save
button, in bulk
- models diag now fetches note type and saves it as required, instead
of holding on top a copy that can grow stale as changes are made in
subdialogs
- both dialogs now perform operations in the backend
- note.model() now fetches the note type on the fly, instead of
holding on to a copy that may become stale
2020-05-12 21:13:34 +10:00
Damien Elmes
ece19da49a avoid renaming completer_, as add-ons depend on it 2020-05-08 18:17:57 +10:00
Damien Elmes
cad3d9e74d python formatting+lints 2020-05-08 17:30:27 +10:00
Damien Elmes
4d33b2d8f7 use qconnect everywhere, and fix some typing issues
a step towards check_untyped_defs in aqt, but there's still 100+
issues to resolve
2020-05-04 13:23:08 +10:00