Skip to content
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
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ repos:
language_version: python3
- id: flake8
language_version: python3
- repo: https://github.com/asottile/reorder_python_imports
rev: v1.3.2
hooks:
- id: reorder-python-imports
args: ['--application-directories=.:src']
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should probably also set --add-import 'from __future__ import absolute_import' and/or the others we want to enforce on all files

- repo: https://github.com/asottile/pyupgrade
rev: v1.8.0
hooks:
Expand Down
1 change: 0 additions & 1 deletion bench/bench_argcomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# 2.7.5 3.3.2
# FilesCompleter 75.1109 69.2116
# FastFilesCompleter 0.7383 1.0760

import timeit

imports = [
Expand Down
1 change: 1 addition & 0 deletions bench/skip.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from six.moves import range

import pytest


Expand Down
26 changes: 12 additions & 14 deletions doc/en/_themes/flask_theme_support.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# flasky extensions. flasky pygments style based on tango style
from pygments.style import Style
from pygments.token import (
Keyword,
Name,
Comment,
String,
Error,
Number,
Operator,
Generic,
Whitespace,
Punctuation,
Other,
Literal,
)
from pygments.token import Comment
from pygments.token import Error
from pygments.token import Generic
from pygments.token import Keyword
from pygments.token import Literal
from pygments.token import Name
from pygments.token import Number
from pygments.token import Operator
from pygments.token import Other
from pygments.token import Punctuation
from pygments.token import String
from pygments.token import Whitespace


class FlaskyStyle(Style):
Expand Down
4 changes: 1 addition & 3 deletions doc/en/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@
#
# All configuration values have a default; values that are commented out
# serve to show the default.

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The full version, including alpha/beta/rc tags.
# The short X.Y version.

import datetime
import os
import sys
import datetime

from _pytest import __version__ as version

Expand Down
5 changes: 3 additions & 2 deletions doc/en/example/assertion/failure_demo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from pytest import raises
import _pytest._code
import six

import _pytest._code
from pytest import raises


def otherfunc(a, b):
assert a == b
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
import py

import pytest

mydir = py.path.local(__file__).dirpath()


Expand Down
1 change: 1 addition & 0 deletions doc/en/example/multipython.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import textwrap

import py

import pytest

pythonlist = ["python2.7", "python3.4", "python3.5"]
Expand Down
1 change: 0 additions & 1 deletion doc/en/example/nonpython/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# content of conftest.py

import pytest


Expand Down
1 change: 1 addition & 0 deletions doc/en/example/py2py3/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys

import pytest

py3 = sys.version_info[0] >= 3
Expand Down
1 change: 1 addition & 0 deletions extra/get_issues.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json

import py
import requests

Expand Down
8 changes: 6 additions & 2 deletions scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
Invoke development tasks.
"""
import argparse
from colorama import init, Fore
from pathlib import Path
from subprocess import check_output, check_call, call
from subprocess import call
from subprocess import check_call
from subprocess import check_output

from colorama import Fore
from colorama import init


def announce(version):
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os

from setuptools import setup


Expand Down
7 changes: 5 additions & 2 deletions src/_pytest/_argcomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@
which should throw a KeyError: 'COMPLINE' (which is properly set by the
global argcomplete script).
"""
from __future__ import absolute_import, division, print_function
import sys
from __future__ import absolute_import
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asottile can you change the tool so for future imports it does one line?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, not configurable intentionally

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asottile not asking for a configuration there ^^

from __future__ import division
from __future__ import print_function

import os
import sys
from glob import glob


Expand Down
11 changes: 7 additions & 4 deletions src/_pytest/_code/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
""" python inspection/code generation API """
from __future__ import absolute_import, division, print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from .code import Code # noqa
from .code import ExceptionInfo # noqa
from .code import Frame # noqa
from .code import Traceback # noqa
from .code import filter_traceback # noqa
from .code import Frame # noqa
from .code import getrawcode # noqa
from .source import Source # noqa
from .code import Traceback # noqa
from .source import compile_ as compile # noqa
from .source import getfslineno # noqa
from .source import Source # noqa
7 changes: 6 additions & 1 deletion src/_pytest/_code/_py2traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
# CHANGES:
# - some_str is replaced, trying to create unicode strings
#
from __future__ import absolute_import, division, print_function, unicode_literals
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import types

from six import text_type


Expand Down
22 changes: 15 additions & 7 deletions src/_pytest/_code/code.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
from __future__ import absolute_import, division, print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import inspect
import pprint
import re
import sys
import traceback
from inspect import CO_VARARGS, CO_VARKEYWORDS
from inspect import CO_VARARGS
from inspect import CO_VARKEYWORDS
from weakref import ref

import attr
import pluggy
import re
from weakref import ref
import _pytest
from _pytest.compat import _PY2, _PY3, PY35, safe_str
from six import text_type
import py
import six
from six import text_type

import _pytest
from _pytest.compat import _PY2
from _pytest.compat import _PY3
from _pytest.compat import PY35
from _pytest.compat import safe_str

builtin_repr = repr

Expand Down
13 changes: 8 additions & 5 deletions src/_pytest/_code/source.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from __future__ import absolute_import, division, print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import ast
from ast import PyCF_ONLY_AST as _AST_FLAG
from bisect import bisect_right
import inspect
import linecache
import sys
import six
import inspect
import textwrap
import tokenize
from ast import PyCF_ONLY_AST as _AST_FLAG
from bisect import bisect_right

import py
import six

cpy_compile = compile

Expand Down
8 changes: 6 additions & 2 deletions src/_pytest/assertion/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
"""
support for presenting detailed information in failing assertions.
"""
from __future__ import absolute_import, division, print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import sys

import six

from _pytest.assertion import util
from _pytest.assertion import rewrite
from _pytest.assertion import truncate
from _pytest.assertion import util


def pytest_addoption(parser):
Expand Down
11 changes: 7 additions & 4 deletions src/_pytest/assertion/rewrite.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
"""Rewrite assertion AST to produce nice error messages"""
from __future__ import absolute_import, division, print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import ast
import errno
import itertools
import imp
import itertools
import marshal
import os
import re
import six
import string
import struct
import sys
import types

import atomicwrites
import py
import six

from _pytest.assertion import util
from _pytest.pathlib import PurePath
from _pytest.compat import spec_from_file_location
from _pytest.pathlib import fnmatch_ex
from _pytest.pathlib import PurePath

# pytest caches rewritten pycs in __pycache__.
if hasattr(imp, "get_tag"):
Expand Down
5 changes: 4 additions & 1 deletion src/_pytest/assertion/truncate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
Current default behaviour is to truncate assertion explanations at
~8 terminal lines, unless running in "-vv" mode or running on CI.
"""
from __future__ import absolute_import, division, print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import os

import six
Expand Down
8 changes: 6 additions & 2 deletions src/_pytest/assertion/util.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
"""Utilities for assertion debugging"""
from __future__ import absolute_import, division, print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import pprint

import _pytest._code
import py
import six

import _pytest._code
from ..compat import Sequence

u = six.text_type
Expand Down
14 changes: 9 additions & 5 deletions src/_pytest/cacheprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@
the name cache was not chosen to ensure pluggy automatically
ignores the external pytest-cache
"""
from __future__ import absolute_import, division, print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import json
from collections import OrderedDict

import attr
import py
import six
import attr

import pytest
import json

from .compat import _PY2 as PY2
from .pathlib import Path, resolve_from_str, rmtree
from .pathlib import Path
from .pathlib import resolve_from_str
from .pathlib import rmtree

README_CONTENT = u"""\
# pytest cache directory #
Expand Down
9 changes: 6 additions & 3 deletions src/_pytest/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
per-test stdout/stderr capturing mechanism.

"""
from __future__ import absolute_import, division, print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import collections
import contextlib
import sys
import os
import io
import os
import sys
from io import UnsupportedOperation
from tempfile import TemporaryFile

import six

import pytest
from _pytest.compat import CaptureIO

Expand Down
Loading