Why does PyCharm say "Typo in word"? [SOLVED]

Why does PyCharm say " typo in word 'txtfile' " in the statement that defines the variable 'txtfile'?

 

8 comments
Comment actions Permalink

Hello, 

 

The  Typo inspection defined 'txtfile' as not included in any dictionary. You can add this word to a dictionary and it will be skipped by the spellchecker in the future.  Please see https://www.jetbrains.com/help/pycharm/spellchecking.html

 

 

0
Comment actions Permalink

Does variable names of the type file have to conform to a dictionary?

0
Comment actions Permalink

Yes, if you would like it not to be marked as "typo" . 

0
Comment actions Permalink

Why do variables of the type 'file' have to conform to a dictionary, when all the other variable types can have whatever name you wish?

0
Comment actions Permalink

Hello Hendrik, 

 

`txtfile`  is not a commonly known word that could exist in a dictionary.  There are 2 dictionaries used for spellchecking: general(https://github.com/JetBrains/intellij-community/blob/9612562bf2d55cb551126cd3e55fdff1029c4c86/spellchecker/src/com/intellij/spellchecker/english.dic)  and for Python(https://github.com/JetBrains/intellij-community/blob/4999f5293e4307870020f1d0d672a3d35a52f22d/python/src/com/jetbrains/python/spellchecker/python.dic)

If a word is split, for example, by '_' sign, there is an additional logic that skips such cases from checking.    

 

0
Comment actions Permalink

But why do variable names of certain variable types have to conform to a dictionary?

0
Comment actions Permalink

The spellcheking does not rely on variable type,  it should be performed for the whole code. 

So you mean that if "txtfile" variable has a different type then it will not be marked as "typo"? Please provide me with a real example.  

0
Comment actions Permalink

I am sorry, I haven't checked this before! 'txtfile' is still marked as a typo in this statement:

txtfile = 234

But 'txt_file' is accepted. I am just not used to IDEs that check the spelling of variable names! :-)

0

Please sign in to leave a comment.