Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TPI: Python Default Problem Matcher #24158

Closed
3 tasks done
anthonykim1 opened this issue Sep 23, 2024 · 7 comments
Closed
3 tasks done

TPI: Python Default Problem Matcher #24158

anthonykim1 opened this issue Sep 23, 2024 · 7 comments

Comments

@anthonykim1
Copy link

anthonykim1 commented Sep 23, 2024

Refs: #24154

Complexity: 3

Create Issue


Thank you in advance for testing Python extension's default problem matcher

Background Information

Problem matcher works very closely with Tasks to parse through the Task Terminal's output and display "problems" or errors in your problems panel. More description on task and problem matcher can be found: https://code.visualstudio.com/docs/editor/tasks#_processing-task-output-with-problem-matchers

The intend of the problem matcher that Python extension provide is to allow users to reference this problem matcher via '$python' in their tasks.json file.

Example of tasks.json file that references $python

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Run Python Script in your desired Folder",
            "type": "shell",
            "command": "python",     <or whichever way you reference your python executable>
            "args": [
                "your_file.py"   <whichever file you want to run with this task+problem matcher attached>
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": "$python"
        }
    ]
}

Setup:

  1. Update the Python extension to the latest pre-release
  2. Open a vscode workspace (or create empty one)
  3. Create tasks.json that runs python file of your choice

Steps:

  1. Have some Python file you would like to run that contains errors/exceptions.
  2. Run Task
  3. Find the task that you have defined in your tasks.json file, where you have reference problem matcher contributed by Python extension.
  4. Run your task
  5. Observe that appropriate errors/problems show up in your problems panel view.

Try killing all of your task terminal and reloading window if errors do not show up in your problems panel.

Warning: You may observe problems not show up in your problems panel if you re-use the same task terminal.
Reference: microsoft/vscode#228883

@anthonykim1 anthonykim1 added triage-needed Needs assignment to the proper sub-team testplan-item labels Sep 23, 2024
@anthonykim1 anthonykim1 added this to the September 2024 milestone Sep 23, 2024
@anthonykim1 anthonykim1 self-assigned this Sep 23, 2024
@karthiknadig karthiknadig changed the title Test Plan Item) Python Default Problem Matcher TPI: Python Default Problem Matcher Sep 23, 2024
@karthiknadig karthiknadig removed the triage-needed Needs assignment to the proper sub-team label Sep 23, 2024
@anthonykim1 anthonykim1 removed their assignment Sep 23, 2024
@sandy081
Copy link
Member

sandy081 commented Sep 24, 2024

Observe that appropriate errors/problems show up in your problems panel view.

I have never seen the problems in the problems view. I tried killing all tasks and open terminals and reload window and none of them works. Is this same as the issue you mentioned or something different?

Image

@sandy081 sandy081 removed their assignment Sep 24, 2024
@connor4312
Copy link
Member

connor4312 commented Sep 24, 2024

Same behavior as Sandeep for me for compilation errors.

Image

Raised errors do work though

@connor4312 connor4312 removed their assignment Sep 24, 2024
@anthonykim1
Copy link
Author

anthonykim1 commented Sep 24, 2024

Thanks for testing this. How about if you try to run some non-pythonic code such as:

Screenshot 2024-09-24 at 11 02 46 AM

I'm thinking it might be the one newline space before the "SyntaxError: " line specifically that is leading to not picking up only syntax errors problems correctly? I would give a try for other non-syntax errors as I've expected pylance to pick up on Syntax errors in your python file and show it in problems panel.

@anthonykim1
Copy link
Author

anthonykim1 commented Sep 24, 2024

Screenshot 2024-09-24 at 11 06 52 AM In fact, for things like syntax/compile time, I would expect Pylance errors should be showing up in your problems panel before&after you run your custom task with my problem matcher.

@bamurtaugh
Copy link
Member

How about if you try to run some non-pythonic code such as:

I do get the output you show in that case:

Image

@connor4312
Copy link
Member

Yes, that works for me

@bamurtaugh
Copy link
Member

bamurtaugh commented Sep 24, 2024

Believe this is the same issue already identified above with no problems appearing in this kind of case:
Image

And another:
Image

@bamurtaugh bamurtaugh removed their assignment Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants