8

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

5
  • I would recommend opening txt files in a different editor, rather than a programming editor. Notepad or nano maybe. Sep 21, 2020 at 7: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, 2020 at 7: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, 2020 at 7: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. Sep 21, 2020 at 7:36
  • 3
    @baduker thanks, I checked and found that this inspection is coming from requirements plugin, not installed by default: plugins.jetbrains.com/plugin/10837-requirements
    – sanyassh
    Sep 21, 2020 at 7:47

1 Answer 1

10

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

1
  • Great fix. This gets the "Worst Default Pattern of the Decade" award. All text files => requirements... Seriously?
    – AirSquid
    Feb 24 at 1:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.