Skip to content

MRG: Better error message for bad tags in Report, and allow tags to be a string - #10183

Merged
agramfort merged 3 commits into
mne-tools:mainfrom
hoechenberger:hoechenberger/issue10164
Jan 22, 2022
Merged

agramfort merged 3 commits into
mne-tools:mainfrom
hoechenberger:hoechenberger/issue10164

Conversation

@hoechenberger

Copy link
Copy Markdown
Member

Fixes #10164

@jasmainak would this already improve things for you a bit?

@hoechenberger hoechenberger changed the title Better error message for bad tags Better error message for bad tags in Report Jan 6, 2022
@hoechenberger
hoechenberger marked this pull request as ready for review January 6, 2022 15:54
@hoechenberger
hoechenberger marked this pull request as draft January 6, 2022 15:55
@larsoner

larsoner commented Jan 6, 2022

Copy link
Copy Markdown
Member

Errors are real

E   AssertionError: Regex pattern 'must be a collection of str' does not match "tags must be an array-like object of str, but got <class 'int'> instead: 123".

@hoechenberger

hoechenberger commented Jan 6, 2022 •

Copy link
Copy Markdown
Member Author

Yes yes, I didn't touch any tests so far, wanted to wait for @jasmainak's opinion first :)

@jasmainak

Copy link
Copy Markdown
Member

yes, looks good! I didn't see the error, mainly the docstring which you said was already fixed.

Also any objection to allowing string as we do in rest of MNE so users don't have to do ['my-tag']? Not a biggie though ...

@hoechenberger

Copy link
Copy Markdown
Member Author

Yes, can do!

Are you okay with the decision to not support spaces in tags? I think supporting those would make our developer life more complicated 😅

@jasmainak

jasmainak commented Jan 7, 2022 •

Copy link
Copy Markdown
Member

sure! I guess if you can add a phrase to the error message that says spaces are unsupported so the user knows what characters are incorrect

Comment thread mne/report/report.py Resolved
@larsoner

Copy link
Copy Markdown
Member
mne/report/tests/test_report.py:911: in test_tags
    r.add_code(code='foo', title='bar', tags=tags)
E   AssertionError: Regex pattern 'must be a collection of str' does not match "tags must be an array-like object of str (without spaces), but got <class 'int'> instead: 123".

Don't forget to mark "Ready for review", too

@hoechenberger

Copy link
Copy Markdown
Member Author

It's not yet ready though 😅

@hoechenberger
hoechenberger force-pushed the hoechenberger/issue10164 branch from 85e1bd4 to fe3e68c Compare January 21, 2022 11:20
@hoechenberger hoechenberger changed the title Better error message for bad tags in Report MRG: Better error message for bad tags in Report, and allow tags to be a string Jan 21, 2022
@hoechenberger
hoechenberger marked this pull request as ready for review January 21, 2022 11:20
Comment thread mne/report/report.py Outdated
raise TypeError(
f'tags must be a collection of str, but got {type(tags)} '
f'instead: {tags}'
f'tags must be a string (without spaces) or an array-like object '

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, looks like the parenthetical (without spaces) should actually go down around line 297. Also I guess it should list the characters ' ', '"', '\n' since it's not just spaces

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good now in 2682fd1

@agramfort
agramfort merged commit ebaaed4 into mne-tools:main Jan 22, 2022
@agramfort

Copy link
Copy Markdown
Member

Thx @hoechenberger

@hoechenberger
hoechenberger deleted the hoechenberger/issue10164 branch January 22, 2022 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

report.add_figure bad tags error not specific enough

4 participants