Skip to content
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

"cannot import name 'parse_bool'" after updating somes packages #1784

Closed
batiste opened this issue Oct 19, 2023 · 10 comments · Fixed by #1792
Closed

"cannot import name 'parse_bool'" after updating somes packages #1784

batiste opened this issue Oct 19, 2023 · 10 comments · Fixed by #1792
Labels
bug Something isn't working mypy-plugin Issues specific to mypy_django_plugin regression Behavior has changed for worse with a release

Comments

@batiste
Copy link

batiste commented Oct 19, 2023

Bug report

I use this version of mypy

What's wrong

mypy.....................................................................Failed

  • hook id: mypy
  • exit code: 2

setup.cfg:34: error: Error importing plugin "mypy_django_plugin.main": cannot import name 'parse_bool' from 'mypy.semanal_shared' (/home/runner/.cache/pre-commit/repo712jqpu7/py_env-python3/lib/python3.11/site-packages/mypy/semanal_shared.cpython-311-x86_64-linux-gnu.so) [misc]
Found 1 error in 1 file (errors prevented further checking)

System information

  • OS:
  • python version: 3.11
  • django version: 4.2.5
  • mypy version: 1.6.1
  • django-stubs version: 4.2.4
  • django-stubs-ext version: 3.2.3
@batiste batiste added the bug Something isn't working label Oct 19, 2023
@batiste batiste changed the title Odd interaction with mypy after updating somes packages "cannot import name 'parse_bool'" after updating somes packages Oct 19, 2023
@intgr
Copy link
Collaborator

intgr commented Oct 19, 2023

Probably related to #1703. @flaeppe any ideas?

@flaeppe
Copy link
Member

flaeppe commented Oct 19, 2023

Not having any ideas really, I'm still seeing a mypy.semanal_shared.parse_bool for v1.6.1.

Ref: https://github.com/python/mypy/blob/v1.6.1/mypy/semanal_shared.py#L469-L475

@intgr intgr added mypy-plugin Issues specific to mypy_django_plugin regression Behavior has changed for worse with a release labels Oct 19, 2023
@intgr
Copy link
Collaborator

intgr commented Oct 19, 2023

Might be some quirk related to the way mypy is compiled with Mypyc

name 'parse_bool' from 'mypy.semanal_shared' (/home/runner/.cache/pre-commit/repo712jqpu7/py_env-python3/lib/python3.11/site-packages/mypy/semanal_shared.cpython-311-x86_64-linux-gnu.so)

If we don't understand this, may make sense to report a mypyc issue: https://github.com/mypyc/mypyc/issues

@flaeppe
Copy link
Member

flaeppe commented Oct 19, 2023

Yeah, that could probably be a reason. Would probably be worth to take it for a spin upstream, see what they say.

@intgr
Copy link
Collaborator

intgr commented Oct 19, 2023

Created upstream issue:

@batiste
Copy link
Author

batiste commented Oct 19, 2023

I am trying to resolve it on my side playing with versions.

But thanks for the quick reaction!

@intgr
Copy link
Collaborator

intgr commented Oct 19, 2023

If there's no resolution in a few days, I'd propose reverting #1703 for the upcoming 4.2.6 release #1780

@intgr
Copy link
Collaborator

intgr commented Oct 22, 2023

I've opened PR #1792 to revert the suspected change.

@batiste does this issue still occur or have you found a work-around?

@batiste
Copy link
Author

batiste commented Oct 23, 2023

My sincerest apologies, I have 2 different pre-commit configurations (one local and one for the CI). And I got confused about this setup. The one that was problematic was this one

`

Once I updated mypy to 1.6.1 the error went away.

@intgr
Copy link
Collaborator

intgr commented Oct 23, 2023

repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.0.1

Doh! Yep, the old mypy version explains it.

Unfortunately the reversion #1792 already got merged. 😅

But we should consider special logic in the plugin to detect old mypy versions and issue a warning, to make detecting such issues easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mypy-plugin Issues specific to mypy_django_plugin regression Behavior has changed for worse with a release
Development

Successfully merging a pull request may close this issue.

3 participants