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

Sort imports and format #112

Merged
merged 7 commits into from
Oct 13, 2024
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/test_corpus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ jobs:
- name: Clear workspace
run: rm -rf "$GITHUB_WORKSPACE/*"

- name: Checkout tests
- name: Checkout workflow ref
uses: actions/[email protected]
with:
fetch-depth: 1
fetch-tags: 'true'
show-progress: 'false'
path: workflow

Expand All @@ -66,7 +65,7 @@ jobs:
path: python-minifier

- name: Run tests
uses: ./.github/actions/run-in-container
uses: dflook/run-in-container@main
with:
image: danielflook/python-minifier-build:python${{ matrix.python }}-2024-09-15
volumes: |
Expand Down Expand Up @@ -111,7 +110,6 @@ jobs:
with:
path: workflow
fetch-depth: 1
fetch-tags: 'true'
show-progress: 'false'

- name: Checkout ref
Expand All @@ -135,7 +133,7 @@ jobs:
show-progress: 'false'

- name: Generate Report
uses: ./.github/actions/run-in-container
uses: dflook/run-in-container@main
with:
image: danielflook/python-minifier-build:python3.13-2024-09-15
volumes: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/xtest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
with:
image: danielflook/python-minifier-build:${{ matrix.python }}-2024-09-15
run: |
exit 0

if [[ "${{ matrix.python }}" == "python3.4" ]]; then
(cd /usr/lib64/python3.4/test && python3.4 make_ssl_certs.py)
elif [[ "${{ matrix.python }}" == "python3.5" ]]; then
Expand Down
7 changes: 7 additions & 0 deletions corpus_test/generate_report.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse
import os
import sys

from dataclasses import dataclass, field
from typing import Iterable

Expand Down Expand Up @@ -182,6 +183,7 @@ def format_difference(compare: Iterable[Result], base: Iterable[Result]) -> str:
else:
return s


def report_larger_than_original(results_dir: str, python_versions: str, minifier_sha: str) -> str:
yield '''
## Larger than original
Expand All @@ -200,6 +202,7 @@ def report_larger_than_original(results_dir: str, python_versions: str, minifier
for entry in larger_than_original:
yield f'| {entry.corpus_entry} | {entry.original_size} | {entry.minified_size} ({entry.minified_size - entry.original_size:+}) |'


def report_unstable(results_dir: str, python_versions: str, minifier_sha: str) -> str:
yield '''
## Unstable
Expand All @@ -218,6 +221,7 @@ def report_unstable(results_dir: str, python_versions: str, minifier_sha: str) -
for entry in unstable:
yield f'| {entry.corpus_entry} | {python_version} | {entry.original_size} |'


def report_exceptions(results_dir: str, python_versions: str, minifier_sha: str) -> str:
yield '''
## Exceptions
Expand All @@ -242,6 +246,7 @@ def report_exceptions(results_dir: str, python_versions: str, minifier_sha: str)
if not exceptions_found:
yield ' None | | |'


def report_larger_than_base(results_dir: str, python_versions: str, minifier_sha: str, base_sha: str) -> str:
yield '''
## Top 10 Larger than base
Expand Down Expand Up @@ -271,6 +276,7 @@ def report_larger_than_base(results_dir: str, python_versions: str, minifier_sha
if not there_are_some_larger_than_base:
yield '| N/A | N/A | N/A |'


def report_slowest(results_dir: str, python_versions: str, minifier_sha: str) -> str:
yield '''
## Top 10 Slowest
Expand All @@ -287,6 +293,7 @@ def report_slowest(results_dir: str, python_versions: str, minifier_sha: str) ->
for entry in sorted(summary.entries.values(), key=lambda entry: entry.time, reverse=True)[:10]:
yield f'| {entry.corpus_entry} | {entry.original_size} | {entry.minified_size} | {entry.time:.3f} |'


def report(results_dir: str, minifier_ref: str, minifier_sha: str, base_ref: str, base_sha: str) -> Iterable[str]:
"""
Generate a report comparing the results of two versions of python-minifier
Expand Down
8 changes: 3 additions & 5 deletions corpus_test/generate_results.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import argparse
import datetime
import gzip
import logging
import os
import sys
import time


import logging


import python_minifier

from result import Result, ResultWriter

try:
Expand All @@ -36,7 +34,6 @@ def minify_corpus_entry(corpus_path, corpus_entry):
with open(os.path.join(corpus_path, corpus_entry), 'rb') as f:
source = f.read()


result = Result(corpus_entry, len(source), 0, 0, '')

start_time = time.time()
Expand Down Expand Up @@ -135,6 +132,7 @@ def corpus_test(corpus_path, results_path, sha, regenerate_results):

print('Finished')


def bool_parse(value):
return value == 'true'

Expand Down
3 changes: 2 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,5 @@ def create_example(option):
# -- Options for intersphinx extension ---------------------------------------

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
intersphinx_mapping = {'python': ('https://docs.python.org/3', None)}

17 changes: 9 additions & 8 deletions hypo_test/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Hypothesis tests

The hypothesis strategies in this directory generate an AST that python can parse.
It does not take care to generate semantically valid programs.
It does not take care to generate semantically valid programs.
Failure cases should shrink into valid programs, though.

TODO:
Assignment targets: (in comprehensions too)

- Tuples, sets??
Starred
Call arguments
Delete targets
ImportFrom levels
functiondef args
Await
f-strings
Starred
Call arguments
Delete targets
ImportFrom levels
functiondef args
Await
f-strings
Empty file added hypo_test/__init__.py
Empty file.
Loading