Whenever I try to import modules in PyCharm, the line of code is highlighted grey and it gives me the error "unused import statement". This seems to happen for every module I try to import. Does anyone know what could be causing this?
Once you call those modules in your script, you should see those greyed out lines turn to their normal color.
You can turn off the code inspection that looks at import, but I don't advise doing that unless you're absolutely sure you don't need it.
I changed my "Unused Symbol" in Settings > Editor > Colors&Fonts > General to just be grey without the underline. This helps me quickly see if I have a variable or an import that I'm not using in my code.
Then I also changed the code inspection severity on unused. Settings > Editor > Inspections > Python > Unused local I set the severity to 'INFO' and 'In All Scopes'.
This allows you to still gain the benefit of knowing you have unused variables without it treating it like an error.
As you can see from my screenshot, I'm not using tz
or tzinfo
even though I imported them. I find that pretty handy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With