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

Feature request: python -m pysnooper user_script.py #231

Open
ChillarAnand opened this issue Feb 21, 2023 · 3 comments
Open

Feature request: python -m pysnooper user_script.py #231

ChillarAnand opened this issue Feb 21, 2023 · 3 comments

Comments

@ChillarAnand
Copy link

ChillarAnand commented Feb 21, 2023

PySnooper has a wide variety of use cases. One of the limitations is not being able to use it without modifying the script.

It would be great if the -m flag is added to run it as a module.

python -m pysnooper user_script.py
@cool-RR
Copy link
Owner

cool-RR commented Feb 21, 2023

Agreed, I was surprised we didn't have a feature request open for this. This was previously attempted at #145 but abandoned. This would make for a good feature. If you'd like to implement it, go ahead.

@cool-RR cool-RR changed the title Add an option to run pysnooper as a module Feature request: Add an option to run pysnooper as a module Feb 21, 2023
@cool-RR cool-RR changed the title Feature request: Add an option to run pysnooper as a module Feature request: python -m pysnooper user_script.py Feb 21, 2023
@itay-goldraich
Copy link

What is the desired behavior?
Is the desire for the code python -m pysnooper user_script.py to run the test for the whole file similarly to @pysnooper.snoop() before every function in the code?
Should this command run the test just for the first function in the user_script?
Maybe this command should run the test just for the __main__() function in the user_script?

I tried thinking about implementing this feature, but I'm not sure what this command should do.

@cool-RR
Copy link
Owner

cool-RR commented May 29, 2024

Hello Itay and welcome to the project.

The desired behavior is to snoop the entire file, regardless of whether it has any tests, a __main__ function or any other functions defined.

Essentially it should be as if someone put a line snoop(argumes).__enter__() before the file. (Untested, treat as pseudocode.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants