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

Clean unused imports and other small code details #257

Merged
merged 1 commit into from
Jan 3, 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyperformance/_benchmark_selections.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
]


from . import _utils, _manifest, _benchmark
from . import _utils, _benchmark


def parse_selection(selection, *, op=None):
Expand Down
1 change: 0 additions & 1 deletion pyperformance/_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
]


from collections import namedtuple
import os.path


Expand Down
2 changes: 0 additions & 2 deletions pyperformance/_pip.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import os
import os.path
import shlex
import subprocess
import sys

from . import _utils, _pythoninfo
Expand Down
6 changes: 2 additions & 4 deletions pyperformance/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import os.path
import shlex
import shutil
import subprocess
import sys
import tempfile
import urllib.request

Expand Down Expand Up @@ -84,7 +82,6 @@ def safe_rmtree(path):
#######################################
# platform utils

import logging
import subprocess
import sys

Expand Down Expand Up @@ -216,7 +213,8 @@ def parse_selections(selections, parse_entry=None):
if isinstance(selections, str):
selections = selections.split(',')
if parse_entry is None:
parse_entry = (lambda o, e: (o, e, None, e))
def parse_entry(o, e):
return (o, e, None, e)

for entry in selections:
entry = entry.strip()
Expand Down
3 changes: 2 additions & 1 deletion pyperformance/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ def _select_benchmarks(raw, manifest):

# Get the raw list of benchmarks.
entries = raw.lower()
parse_entry = (lambda o, s: _benchmark_selections.parse_selection(s, op=o))
def parse_entry(o, s):
return _benchmark_selections.parse_selection(s, op=o)
parsed = _utils.parse_selections(entries, parse_entry)
parsed_infos = list(parsed)

Expand Down
4 changes: 2 additions & 2 deletions pyperformance/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def cmd_list_groups(manifest, *, showtags=True):


def cmd_venv_create(options, root, python, benchmarks):
from . import _pythoninfo, _venv
from . import _venv
from .venv import Requirements, VenvForBenchmarks

if _venv.venv_exists(root):
Expand All @@ -73,7 +73,7 @@ def cmd_venv_create(options, root, python, benchmarks):


def cmd_venv_recreate(options, root, python, benchmarks):
from . import _pythoninfo, _venv, _utils
from . import _venv, _utils
from .venv import Requirements, VenvForBenchmarks

requirements = Requirements.from_benchmarks(benchmarks)
Expand Down
1 change: 0 additions & 1 deletion pyperformance/compare.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import csv
import os.path
import math
import sys

import pyperf
import statistics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import contextlib
from pathlib import Path
import time

import docutils
from docutils import core
Expand Down
11 changes: 6 additions & 5 deletions pyperformance/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ def create_venv(root=None, python=sys.executable, *, verbose=False):
if not root:
tmpdir = tempfile.mkdtemp()
root = os.path.join(tmpdir, 'venv')
cleanup = (lambda: shutil.rmtree(tmpdir))
def cleanup():
return shutil.rmtree(tmpdir)
else:
cleanup = (lambda: None)
def cleanup():
return None
run_cmd(
python or sys.executable, '-m', 'venv', root,
capture=not verbose,
Expand Down Expand Up @@ -160,9 +162,8 @@ def addClassCleanup(cls, cleanup):
NON_WINDOWS_ONLY = unittest.skipIf(os.name == 'nt', 'skipping Windows')

# XXX Provide a way to run slow tests.
SLOW = (lambda f:
unittest.skip('way too slow')(
mark('slow', f)))
def SLOW(f):
return unittest.skip('way too slow')(mark('slow', f))


class Functional(Compat):
Expand Down
1 change: 0 additions & 1 deletion pyperformance/tests/data/bm_local_wheel/run_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

import pyperf
from this_is import en_us


def bench():
Expand Down
1 change: 0 additions & 1 deletion pyperformance/tests/test_commands.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import os.path
import shutil
import sys
import textwrap
import unittest

Expand Down
3 changes: 1 addition & 2 deletions pyperformance/tests/test_python.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import sys
import types
import unittest

from pyperformance import tests, _python
from pyperformance import _python


class GetIDTests(unittest.TestCase):
Expand Down