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

3.12 #6

Merged
merged 5 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
pull_request:
push:
branches: [main]

jobs:
mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
architecture: x64
- run: pip install nox==2019.11.9
- run: pip install poetry==1.2.2
- run: nox --session mypy

test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{matrix.python-version}}
architecture: x64
- run: pip install nox==2022.11.21
- run: pip install poetry==1.2.2
- run: nox --sessions test-${{matrix.python-version}}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__pycache__
dist
.python-version
.coverage
.coverage*
6 changes: 4 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
exclude: tests/.*_samples

repos:
- hooks:
- id: check-yaml
Expand Down Expand Up @@ -31,11 +33,11 @@ repos:
rev: v3.9.0
hooks:
- args:
- --py38-plus
- --py37-plus
id: reorder-python-imports
- hooks:
- args:
- --py38-plus
- --py37-plus
id: pyupgrade
repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
Expand Down
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# minimize source code
# pysource-minimize

If you build a linter, formatter or any other tool which has to analyse python source code you might end up searching bugs in pretty large input files.


`pysource_minimize` is able to remove everything from the python source which is not related to the problem.

## CLI

You can use `pysource-minimize` from the command line like follow:

```bash
pysource-minimize --file bug.py --track "Assertion" -- python bug.py
```

This will run `python bug.py` and try to find the string "Assertion" in the output.
The `--file bug.py` gets minimized as long as "Assertion" is part of the output of the command.

![example](example.gif)

## API
Example:
``` pycon
>>> from pysource_minimize import minimize
Expand All @@ -19,5 +32,4 @@ Example:
>>> print(minimize(source, lambda new_source: "bug" in new_source))
"""bug"""


```
Binary file added example.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import nox

nox.options.sessions = ["clean", "test", "report", "docs"]
nox.options.sessions = ["clean", "test", "report", "mypy"]
nox.options.reuse_existing_virtualenvs = True


Expand All @@ -17,7 +17,7 @@ def clean(session):
def mypy(session):
session.install("poetry")
session.run("poetry", "install", "--with=dev")
session.run("mypy", "src", "tests")
session.run("mypy", "pysource_minimize", "tests")


@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11"])
Expand All @@ -41,11 +41,11 @@ def report(session):
except:
pass
session.run("coverage", "html")
session.run("coverage", "report", "--fail-under", "94")
session.run("coverage", "report")


@nox.session(python="python3.10")
def docs(session):
session.install("poetry")
session.run("poetry", "install", "--with=doc")
session.run("mkdocs", "build")
# @nox.session(python="python3.10")
# def docs(session):
# session.install("poetry")
# session.run("poetry", "install", "--with=doc")
# session.run("mkdocs", "build")
Loading