Is there a way to disable Python type hinting on code autocompletion in pycharms?

This post relates to pycharm and Python code.

While working with autocompletion, pycharm automatically inserts type hints (see screenshots).

Suggestion:

Result:

 

I do not wish to use type hinting on my current project and automatic type hinting insertion creates unnecessary work of having to remove types all the time, and makes autocompletion in general a hinderance rather than help.

I've had a look through pycharm settings but could not find any option to disable this feature.

Could you please clarify if there is a way for users to disable this behaviour?

Thanks

1
6 comments

Hi, could you please provide a minimal working code sample to reproduce the issue, along with Logs from **Help | Collect Logs and Diagnostic Data**?

For the logs, you can use uploading service at https://uploads.jetbrains.com/ , and provide upload ID in your reply. 

One case when PyCharm completes the method declaration with type hints, is when you override this method in a subclass, meaning that the original method declaration is correct and all type hints should be resolved.

0

Hi,

There is no "minimal" code sample here. It looks like code-independent issue.

The issue also generates no errors which means that your standard request for logs is not relevant.

Yes, I believe you may be onto something. I was overriding a base class method of a class with annotated parameters (via pyi files, not the source). It is my opinion that there should be a switch to disable propagation of types from 3rd party classes to your own. That's because, just like in my case, the 3rd party uses annotation, but my project doesnt. Copying the signature of the overriden method like-for-like, without taking into account the preferences of a particular user or project, is daft.

 

 

0

The logs can be used to check your IDE version and some other parameters. At least please specify your IDE version.

Unfortunately, I couldn't find a situation when PyCharm suggests unresolved type hints, so having a code/project sample would help to reproduce the issue, and understand the root cause or create a proper bug report.

0

Hi Andrey,

I've ralised that I'm on 2021.3 and a slightly newer 2021.3.3 is now available for my platform.

I'm going to install it this weekend, and if the issue persists, I'll build a PoC for you.

 

0

Having the same issue. Andrey, the question is not about the correctness of the completed code, but difference in programming styles and whether this feature is wanted or not. This "feature" always causes unnecessary work for me and all my colleagues (guess what, same code style).

The problem is that most people don't complain about this and find workarounds, so that leaves 'annoying users' like me to be the ones to complain about something that a lot of users simply don't want.

We do a lot with Qt and the difference in readability between these two, for example, is monumentally different, I'm sure you agree:

def columnCount(self, parent:Union[PySide6.QtCore.QModelIndex, PySide6.QtCore.QPersistentModelIndex]=...) -> int:
pass

 

def columnCount(self, parent):
pass

That said, it would be wonderful to have an option to disable these hints.

0

Hello Bmodone,

 

Could you please share a whole simplified code example? I would like to reproduce this.  

Thank you in advance! 

0

Please sign in to leave a comment.