-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MRG: Add return type hints to read_evokeds()
, read_raw()
#12250
Conversation
read_evokeds()
, read_raw()
read_evokeds()
, read_raw()
This comment has been minimized.
This comment has been minimized.
Looks good to me so far. Is it reasonable to add |
I will look into this, @larsoner |
@larsoner I added the foundations for MyPy testing, but I don't have time to adjust the CI configurations etc
Changing the
Not the greatest error message, but it does discover the bug! There's an issue with
I've gotten red squiggly lines and no tab completion with |
I will write a changeog entry later |
Maybe but for now I just ignore Based on the link @drammock posted in #12249, I think we're on step https://mypy.readthedocs.io/en/stable/existing_code.html#prioritise-annotating-widely-imported-modules at this point, so @hoechenberger if you add a |
'no-untyped-call', | ||
'no-untyped-def', | ||
'misc', | ||
'assignment', | ||
'operator', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@larsoner I don't need to add a single one of these to successfully run mypy mne/
without errors. Did you only add those in anticipation of future errors? I'd rather remove or comment out anything we don't need right now. I'm using MyPy 1.7.1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you were running it with --strict
. Why?
I don't think we should run with --strict
for now.
MNE is basically not typed at all; telling MyPy to be strict
is just setting us up for all kinds of trouble
Also the MyPy docs say:
Note: the exact list of flags enabled by running --strict may change over time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it's better to know and be explicit here but we can remove it if you want
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I'd like to keep the comments though because they do indicate things we can work on in the future)
* upstream/main: MRG: Use ruff-format instead of Black (mne-tools#12261) MAINT: Make selenium optional and use on CircleCI (mne-tools#12263) MAINT: Post-release deprecations (mne-tools#12265) MAINT: Replace `Path.parent.parent` with `Path.parents[N]` in tests (mne-tools#12257)
@hoechenberger fixed a conflict and added to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@drammock feel free to review and approve then we can merge I think assuming @hoechenberger is also happy
This looks like a problem with Pylance. Is there anything useful logged in the "Python language server" log window? |
nothing useful to my eye:
all of this was up within ~15 seconds of opening vscode. did a Ctrl+space after |
Thanks! Can you check that you have the following settings in VS Code: "python.analysis.indexing": true, // this is the default, but check if it's really on
"python.analysis.userFileIndexingLimit": -1, Lastly, you can set "python.analysis.logLevel": "Trace" to get debugging info – maybe this can give us some clues! |
I've also just enabled the "persist indices to disk for all 3rd party libraries" so maybe once it's gone through everything once it will actually become performant? 🤞🏻 |
it finally slowed down. every single message is
ctrl+space still shows "loading..." both before and after closing/reopening the IDE |
How did you install MNE? |
editable pip install.
-------- Original Message --------
…On Dec 5, 2023, 17:07, Richard Höchenberger wrote:
How did you install MNE?
—
Reply to this email directly, [view it on GitHub](#12250 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AAN2AU543HCW5M2DJ2SNFBDYH6SMPAVCNFSM6AAAAABABSTQQGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBRG43TENBUGU).
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Can you do a non-editable install? After that one, I'm out of ideas… |
FWIW, everything works fine for me, even with an editable install. |
If the editable install is working for you out of the box, this indicates that your Pylance is actually not picking up the "installed" MNE, but rather the one in your current working directory / workspace. So this is not a valid test for either, editable and non-editable install. You need to use a workspace outside of the |
Can we please switch to Hatchling ASAP? I keep forgetting that editable installs do not work with Setuptools... And yes, installing it as non-editable in a new venv outside of the MNE source works for me. |
Sure but this still wouldn't resolve this issue here. As will Python… |
OK, so as a dev I will basically never be able to check if these sorts of things are working? I am not going to roll a second venv just to test this. |
Errm … If you're running all your tests from within the This just to say that this problem affects all parts of Python package development. It's not isolated to type hints. It has nothing to do with using a venv or not. The Python import system is just awful in this regard. |
Yes, that's what CI should test, not any dev. |
So what was your point again? :D |
update:
$ mamba create -n typehints pip
$ mamba activate typehints
$ pip install git+https://github.com/mne-tools/mne-python.git@main then launch vscode from anywhere (both I can even get the suggestions to work if I launch vscode from a terminal with |
Here's what I did: $ cd /opt/mne/python
$ git checkout -b hatchling hoechenberger/hatchling
$ pip install -e .
$ code . No completion, still "Loading..." forever. vscode's bottom bar shows If I instead do Is that the expected pattern? Is there a chance that some cruft is causing the failure? in the root of my MNE clone I have (among other things) the folders |
It's definitely not the expected behavior Can you try to create a fresh clone of my branch and use that? |
Do you get completions with other Python packages? Did the problem not occur before we merged this PR? |
Or use |
This sounds like your VS Code installation is broken. Can you try to reinstall and maybe clean out your user and workspace (.vscode) settings? |
yes, e.g., numpy
not sure, I didn't typically use this feature before
Nothing changed after doing this.
Ultimately I did just fix it, by disabling the |
reST is poision, I'm tellin' ya! 😅🥹 Great to hear things are working for you now! |
rST is not the problem here. it's the vscode extension that relies on silently running sphinx builds in the background in order to offer rST completion hints for crossreferences. A small benefit that is not worth the complexity and cost. |
I was really just trying to make a joke :) But I do dislike reST, that's for sure :D |
…ls#12250) Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
Closes #12249
x-ref #12243
This PR adds return type hints for
read_evokeds()
andread_raw()
.I decided to annotate
read_raw()
asBaseRaw
, as this is the parent class shared among all raw readers.Neat:
Turns out that since all specific raw readers (
read_raw_*()
) are structured in a simple fashion and havereturn RawXXX()
as their last line of code, VS Code can trivially find out the correct return types of those functions without any additional type hints!Same goes for
read_epochs()
, hence no changes are required there either.Still, our docstrings are, strictly speaking, incorrect;
read_raw_X()
returns aRawX
instance, notRaw
; andread_epochs()
returnsEpochsFIF
, notEpochs
. Just something to keep in mind for a future cleanup or so.