10

I have requirements.txt file in my project and PyCharm works perfectly fine with it. However, it also checks every other txt file and displays misleading error messages. For example, having foo.txt file with a string

bar baz

written in it produces the following message:

<versionspec>, RequirementsTokenType.COMMENT, RequirementsTokenType.EOL, RequirementsTokenType.LSBRACE, RequirementsTokenType.SEMICOLON or RequirementsTokenType.WHITE_SPACE expected, got 'baz'

I definitely don't want PyCharm to treat all txt files like requirements file, how can I change this strange behavior?

PyCharm 2020.2.1 CE

sanyassh
  • 8,100
  • 13
  • 36
  • 70
  • I would recommend opening txt files in a different editor, rather than a programming editor. Notepad or nano maybe. – James Ashwood Sep 21 '20 at 07:28
  • 1
    @Linux4Life531 why should I bother with other editors if I have preferred one, which is one among the best IDEs for Python programming? Fixing such a minor issue like described in the question is better options than switching to another editor. – sanyassh Sep 21 '20 at 07:31
  • 1
    Are you using a plugin to check the `requirements.txt` files or is this from the default editor? And how does this error come up? – baduker Sep 21 '20 at 07:33
  • Can you check Settings -> Editor -> File Types if there isn't something unusual about requirements? I dont see `requirements.txt` there as a recognized file type at all, so having a plugin for `requirements.txt` handling seems like the most plausible scenario. – yedpodtrzitko Sep 21 '20 at 07:36
  • 3
    @baduker thanks, I checked and found that this inspection is coming from requirements plugin, not installed by default: https://plugins.jetbrains.com/plugin/10837-requirements – sanyassh Sep 21 '20 at 07:47

2 Answers2

14

This behaviour is caused by the requirements plugin, you can fix it by removing the patterns as shown bellow: requirements plugin

Juliano Petronetto
  • 1,067
  • 13
  • 15
  • 4
    Great fix. This gets the "Worst Default Pattern of the Decade" award. All text files => requirements... Seriously? – AirSquid Feb 24 '23 at 01:43
-1

You can also avoid this problem by using markdown suffixes (.md) for non-requirements files.

CLSoVan
  • 20
  • 5