-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from 15r10nk/3.13
3.13
- Loading branch information
Showing
16 changed files
with
160 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Changes here will be overwritten by Copier | ||
_commit: v0.0.5 | ||
_src_path: [email protected]:15r10nk/project-template.git | ||
full_coverage: false | ||
github_user: 15r10nk | ||
insider_only: false | ||
module_name: pysource_minimize | ||
project_description: minimize python source code | ||
project_main: true | ||
project_name: pysource-minimize | ||
python_versions: | ||
- '3.8' | ||
- '3.9' | ||
- '3.10' | ||
- '3.11' | ||
- '3.12' | ||
- '3.13' | ||
show_project_logo: false | ||
use_mkdocs: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Contributing | ||
Contributions are welcome. | ||
Please create an issue before writing a pull request so we can discuss what needs to be changed. | ||
|
||
# Testing | ||
The code can be tested with [hatch](https://hatch.pypa.io/latest/) | ||
|
||
* `hatch run cov:test` can be used to test all supported python versions and to check for coverage. | ||
* `hatch run +py=3.10 all:test -- --sw` runs pytest for python 3.10 with the `--sw` argument. | ||
|
||
|
||
|
||
# Commits | ||
Please use [pre-commit](https://pre-commit.com/) for your commits. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,40 @@ | ||
<!-- -8<- [start:Header] --> | ||
|
||
|
||
![ci](https://github.com/15r10nk/pysource-minimize/actions/workflows/ci.yml/badge.svg?branch=main) | ||
[![Docs](https://img.shields.io/badge/docs-mkdocs-green)](https://15r10nk.github.io/pysource-minimize/) | ||
[![pypi version](https://img.shields.io/pypi/v/pysource-minimize.svg)](https://pypi.org/project/pysource-minimize/) | ||
![Python Versions](https://img.shields.io/pypi/pyversions/pysource-minimize) | ||
![PyPI - Downloads](https://img.shields.io/pypi/dw/pysource-minimize) | ||
[![GitHub Sponsors](https://img.shields.io/github/sponsors/15r10nk)](https://github.com/sponsors/15r10nk) | ||
|
||
# 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. | ||
<!-- -8<- [end:Header] --> | ||
|
||
`pysource_minimize` is able to remove everything from the python source which is not related to the problem. | ||
## Installation | ||
|
||
## CLI | ||
|
||
You can use `pysource-minimize` from the command line like follow: | ||
You can install "pysource-minimize" via [pip](https://pypi.org/project/pip/): | ||
|
||
```bash | ||
pysource-minimize --file bug.py --track "Assertion" -- python bug.py | ||
``` bash | ||
pip install pysource-minimize | ||
``` | ||
|
||
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. | ||
|
||
> [!WARNING] | ||
> Be careful when you execute code which gets minimized. | ||
> It might be that some combination of the code you minimize erases your hard drive | ||
> or does other unintended things. | ||
## Key Features | ||
|
||
![example](example.gif) | ||
- **list** of features ... | ||
|
||
|
||
## Usage | ||
|
||
## API | ||
Example: | ||
``` pycon | ||
>>> from pysource_minimize import minimize | ||
usage ... | ||
|
||
>>> source = """ | ||
... def f(): | ||
... print("bug"+"other string") | ||
... return 1+1 | ||
... f() | ||
... """ | ||
<!-- -8<- [start:Feedback] --> | ||
## Issues | ||
|
||
>>> print(minimize(source, lambda new_source: "bug" in new_source)) | ||
"""bug""" | ||
If you encounter any problems, please [report an issue](https://github.com/15r10nk/pysource-minimize/issues) along with a detailed description. | ||
<!-- -8<- [end:Feedback] --> | ||
|
||
``` | ||
## License | ||
|
||
Distributed under the terms of the [MIT](http://opensource.org/licenses/MIT) license, "pysource-minimize" is free and open source software. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,83 @@ | ||
[tool.poetry] | ||
name = "pysource-minimize" | ||
version = "0.6.3" | ||
description = "minimize python source code" | ||
authors = ["Frank Hoffmann"] | ||
[build-system] | ||
build-backend = "hatchling.build" | ||
requires = ["hatchling"] | ||
|
||
[project] | ||
authors = [ | ||
{name = "Frank Hoffmann", email = "[email protected]"} | ||
] | ||
classifiers = [ | ||
"Development Status :: 4 - Beta", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"Programming Language :: Python :: 3.13", | ||
"Programming Language :: Python :: Implementation :: CPython", | ||
"Programming Language :: Python :: Implementation :: PyPy" | ||
] | ||
dependencies = [ | ||
"rich >=12.6.0", | ||
"astunparse >=1.6.3", | ||
"click >=8.1.7", | ||
] | ||
description = 'minimize python source code' | ||
keywords = [] | ||
license = "MIT" | ||
name = "pysource-minimize" | ||
readme = "README.md" | ||
packages = [{include = "pysource_minimize"}] | ||
requires-python = ">=3.8" | ||
version="0.6.3" | ||
|
||
|
||
[project.scripts] | ||
pysource-minimize = "pysource_minimize.__main__:main" | ||
|
||
|
||
[project.urls] | ||
Documentation = "https://github.com/15r10nk/pysource-minimize#readme" | ||
Issues = "https://github.com/15r10nk/pysource-minimize/issues" | ||
Source = "https://github.com/15r10nk/pysource-minimize" | ||
|
||
[tool.black] | ||
target-version = ["py38"] | ||
|
||
[tool.commitizen] | ||
changelog_incremental = true | ||
major_version_zero = true | ||
tag_format = "v$major.$minor.$patch$prerelease" | ||
update_changelog_on_bump = true | ||
version_files = [ | ||
"pysource_minimize/__init__.py:version" | ||
"src/pysource_minimize/__init__.py:version" | ||
] | ||
version_provider = "poetry" | ||
|
||
[tool.poetry.dependencies] | ||
python = ">=3.7" | ||
asttokens = ">=2.0.8" | ||
rich = ">=12.6.0" | ||
astunparse = ">=1.6.3" | ||
click = ">=8.1.7" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
pytest = ">=7.1.3" | ||
pytest-subtests = ">=0.8.0" | ||
pytest-xdist = {extras = ["psutil"], version = ">=3.1.0"} | ||
coverage-enable-subprocess = ">=1.0" | ||
coverage = ">=6.5.0" | ||
mypy = ">=1.2.0" | ||
pysource-codegen = ">=0.4.1" | ||
|
||
[tool.poetry.scripts] | ||
pysource-minimize = "pysource_minimize.__main__:main" | ||
version_provider = "pep621" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" | ||
[tool.hatch.envs.hatch-test] | ||
extra-dependencies = [ | ||
"pysource-codegen>=0.4.1", | ||
"inline-snapshot", | ||
"pytest-xdist[psutil] >=3.1.0", | ||
] | ||
[[tool.hatch.envs.hatch-test.matrix]] | ||
python=['3.8',"3.9","3.10","3.11","3.12","3.13"] | ||
|
||
[tool.coverage.run] | ||
source = ["tests","pysource_minimize"] | ||
parallel = true | ||
branch = true | ||
data_file = "$TOP/.coverage" | ||
|
||
[tool.coverage.report] | ||
exclude_lines = ["assert False", "raise NotImplemented"] | ||
[[tool.hatch.envs.mypy.matrix]] | ||
python=['3.8',"3.10","3.11","3.12","3.13"] | ||
|
||
[tool.black] | ||
force-exclude = "tests/.*_samples" | ||
skip_magic_trailing_comma = true | ||
[tool.hatch.envs.mypy] | ||
extra-dependencies=["mypy"] | ||
scripts.test = ["mypy src"] | ||
|
||
[tool.hatch.envs.docs] | ||
dependencies = [ | ||
"mkdocs>=1.4.2", | ||
"mkdocs-material[imaging]>=8.5.10", | ||
"mkdocstrings>=0.19.0" | ||
] | ||
scripts.serve = ["mkdocs serve {args}"] | ||
|
||
[tool.mypy] | ||
exclude="tests/.*_samples" | ||
[tool.hatch.version] | ||
path = "src/pysource_minimize/__init__.py" |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
tests/needle_samples/1fb072a0e339dd5ea40cb67ab63630fb74aaebc601b2239f5c4e834e9eaf158b.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
type name_0[name_4 = needle_17597] = name_1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.