Closed brettcannon closed 11 months ago
It's nice that you're actively trying to improve!
I can't remember an exact list of the issues I ran into, but I'll try to list a few as I encounter them, as I still will use VSCode when IntelliJ is not open and I need to make a quick edit. If relevant, our default config is in .vscode.dist.
aqt/__init__.py
it lists a bunch of undefined variables due to the wildcard imports from aqt.qt. IntelliJ seems to handle this correctly: no warnings, and the imports can be navigated to. Also a little annoying is that once the file has been opened and remains open in a background tab, the warnings are still listed at the bottom. We use these wildcard re-imports quite a bit across our codebase so our code can be Qt5/6-independent (and maybe one day work with PySide too), so this is somewhat of a pain point at the moment. Importing the specific symbols we need silences the warning, but VSCode doesn't understand the underlying types, and we can't navigate to them, as they were imported with wildcards in aqt.qt (it's not really practical to manually list out the entire Qt API)def sync_media(self, message: anki.sync_pb2.SyncAuth) -> anki.generic_pb2.Empty
is typed as a return value of Any in VSCode unless you import anki.generic_pb2 first.Thanks for the input! I'll pass it along to the appropriate folks since that seems to all be Pylance-specific (you can also try using Jedi as your auto-complete provider in case it gives you a better experience).
Jedi seems worse unfortunately - no warnings in the first case, but doesn't recognize the types either, and in the second case, it doesn't even know sync_media() exists.
In case this helps someone else, I figured out that In neovim, with pyright as LSP, you can get anki imports working by adding a pyproject.toml
with:
[tool.pyright]
extraPaths = [
"/path/to/anki/pylib",
"/path/to/anki/qt"
]
where /path/to/anki
is a checkout of https://github.com/ankitects/anki
(Since this is specific to your docs, I figured this didn't belong in your forum, but if that's wrong than I apologize.)
https://addon-docs.ankiweb.net/editor-setup.html#pycharm-setup says, "You can also use other editors like Visual Studio Code, but we find PyCharm gives the best results." As the developer manager for the Python extension in VS Code, I was wondering if you could elaborate as to what VS Code is missing that causes you to recommend PyCharm explicitly over us?