Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Vertical line in place of Union does not pass the types check #79

Closed
AndreyKarnauhov opened this issue Oct 2, 2022 · 4 comments
Closed
Assignees

Comments

@AndreyKarnauhov
Copy link
Contributor

AndreyKarnauhov commented Oct 2, 2022

Example of a commit with this issue:
0da5b89

main.py line 186:

if not (is_dic_correct(frequencies, False, str, int | float) and my_isinstance(top, int) and top > 0):

Check types output:

lab_1_keywords_tfidf/main.py:186: error: Argument 3 to "is_dic_correct" has incompatible type "Type[str]"; expected "Union[int, float, str, Tuple[Any, ...]]"  [arg-type]
lab_1_keywords_tfidf/main.py:186: error: Unsupported left operand type for | ("Type[int]")  [operator]
@AndreyKarnauhov AndreyKarnauhov changed the title Vertical line instead of Union does not pass the types check Vertical line in place of Union does not pass the types check Oct 2, 2022
@artyomtugaryov
Copy link
Contributor

Can you share a link to this CI run?

@artyomtugaryov
Copy link
Contributor

@AndreyKarnauhov
Copy link
Contributor Author

Merging dictionaries with | provokes an error as well.

Commit: e15df15

CI run: https://github.com/fipl-hse/2022-2-level-labs/actions/runs/3185903115/jobs/5195982864

Line 101 in start.py:

FINAL_CUMULATIVE_SCORE = KEYWORD_PHRASES_WITH_SCORES | CUMULATIVE_SCORE_WITH_STOP_WORDS

Check types output:

lab_2_keywords_cooccurrence/start.py:101: error: Unsupported left operand type for | ("Mapping[Tuple[str, ...], float]")  [operator]
lab_2_keywords_cooccurrence/start.py:101: error: Unsupported left operand type for | ("None")  [operator]
lab_2_keywords_cooccurrence/start.py:101: note: Both left and right operands are unions

@artyomtugaryov
Copy link
Contributor

I investigated the bug and found that the problem is in mypy - python/mypy#12392
And we just have to wait for a decision from the mypy project. The workaround I can suggest is just use Union instead of |

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants