question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clearer errorr message for "Cannot parse" when targetting multiple version

See original GitHub issue

Is your feature request related to a problem? Please describe.

I was working on a project that is only intended to run on Python 3.10. However, the black configuration incorrectly listed multiple target versions because I copied the file from a different project.

When I tried to format a file with a match statement, the error was

error: cannot format foo.py: Cannot parse: 2:6: match bar:

I was initially confused as I knew that black had added Python 3.10 support. Then I noticed my mistake. By saying that the code should target a multiple Python versions, using a match statement would not be valid.

Describe the solution you’d like

If black encounters a parsing error and it was configured to target multiple Python versions, I think it would be helpful to mention that the syntax “might be valid, but not across all target versions”. This would be a hint to the user to think about if they should be using that syntax or that black is misconfigured (as it was in my case).

Describe alternatives you’ve considered

It would require more work, but the parser could back track and attempt each of the parser for each of the listed target versions. That would allow black provide an even more specific error message. Something like “this is valid for Python 3.10, but targeting Python 3.10 and 3.9”, while also being able to identify an invalid syntax.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Elvis020commented, Oct 15, 2022

ok, cool. Looks like it’s left for a pending reviewer to take a look

0reactions
nnreposcommented, Oct 15, 2022

I think this issue should be marked closed, correct me if I am wrong

hey, usually an issue is closed when a PR is merged. this is done automatically if the PR contains something like closes #3294.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting .NET Framework Targeting Errors - MSBuild
NET Framework applications, open Solution Explorer, choose Show All Files, and then edit the app.config file in the XML editor of Visual Studio....
Read more >
Configuration Error related to targetFramework in web.config
Parser Error Message: The 'targetFramework' attribute in the element of the Web.config file is used only to target version 4.0 and later of ......
Read more >
Resolve "HIVE_BAD_DATA: Error parsing field value for field ...
When I query data in Amazon Athena, I get an error similar to one of the following: "HIVE_BAD_DATA: Error parsing field value for...
Read more >
Error Messages (GNU make)
The first means the target-pattern part of the rule is empty; the second means there are multiple pattern characters ( % ) in...
Read more >
Behavior changes: apps targeting API 29+ - Android Developers
Untrusted apps that target Android 10 cannot invoke execve() directly on ... a different class loader hierarchy than the one used in previous...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found