Skip to content

Automated / semi-automated python3 upgrades #5368

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

Merged
merged 12 commits into from
Jun 3, 2019
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
13 changes: 7 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ repos:
args: [--safe, --quiet]
language_version: python3
- repo: https://github.com/asottile/blacken-docs
rev: v0.5.0
rev: v1.0.0
hooks:
- id: blacken-docs
additional_dependencies: [black==19.3b0]
language_version: python3
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.2.2
rev: v2.2.3
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: fix-encoding-pragma
args: [--remove]
- id: check-yaml
- id: debug-statements
exclude: _pytest/debugging.py
Expand All @@ -31,14 +32,14 @@ repos:
rev: v1.4.0
hooks:
- id: reorder-python-imports
args: ['--application-directories=.:src']
args: ['--application-directories=.:src', --py3-plus]
- repo: https://github.com/asottile/pyupgrade
rev: v1.15.0
rev: v1.18.0
hooks:
- id: pyupgrade
args: [--keep-percent-format]
args: [--py3-plus]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.3.0
rev: v1.4.0
hooks:
- id: rst-backticks
- repo: local
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- test $(python -c 'import sys; print("%d%d" % sys.version_info[0:2])') = 37

# Full run of latest supported version, without xdist.
- env: TOXENV=py37
- env: TOXENV=py37 PYTEST_COVERAGE=1
Copy link
Contributor

Choose a reason for hiding this comment

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

We do not need this, do we?
We have py37-xdist with coverage already (at least).

Copy link
Member

Choose a reason for hiding this comment

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

Not sure, this fixed the coverage on the PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd guess it was the rebase that fixed it.

We can revert this and this - after things stabilized a bit.. :)

python: '3.7'

# Coverage tracking is slow with pypy, skip it.
Expand Down
1 change: 0 additions & 1 deletion bench/bench.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import sys

if __name__ == "__main__":
Expand Down
1 change: 0 additions & 1 deletion bench/bench_argcomplete.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# 10000 iterations, just for relative comparison
# 2.7.5 3.3.2
# FilesCompleter 75.1109 69.2116
Expand Down
1 change: 0 additions & 1 deletion bench/empty.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# -*- coding: utf-8 -*-
for i in range(1000):
exec("def test_func_%d(): pass" % i)
1 change: 0 additions & 1 deletion bench/manyparam.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import pytest


Expand Down
3 changes: 0 additions & 3 deletions bench/skip.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from six.moves import range

import pytest

SKIP = True
Expand Down
1 change: 0 additions & 1 deletion doc/en/_themes/flask_theme_support.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# flasky extensions. flasky pygments style based on tango style
from pygments.style import Style
from pygments.token import Comment
Expand Down
19 changes: 9 additions & 10 deletions doc/en/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# pytest documentation build configuration file, created by
# sphinx-quickstart on Fri Oct 8 17:54:28 2010.
Expand Down Expand Up @@ -63,9 +62,9 @@
master_doc = "contents"

# General information about the project.
project = u"pytest"
project = "pytest"
year = datetime.datetime.utcnow().year
copyright = u"2015–2019 , holger krekel and pytest-dev team"
copyright = "2015–2019 , holger krekel and pytest-dev team"


# The language for content autogenerated by Sphinx. Refer to documentation
Expand Down Expand Up @@ -233,8 +232,8 @@
(
"contents",
"pytest.tex",
u"pytest Documentation",
u"holger krekel, trainer and consultant, http://merlinux.eu",
"pytest Documentation",
"holger krekel, trainer and consultant, http://merlinux.eu",
"manual",
)
]
Expand Down Expand Up @@ -266,16 +265,16 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [("usage", "pytest", u"pytest usage", [u"holger krekel at merlinux eu"], 1)]
man_pages = [("usage", "pytest", "pytest usage", ["holger krekel at merlinux eu"], 1)]


# -- Options for Epub output ---------------------------------------------------

# Bibliographic Dublin Core info.
epub_title = u"pytest"
epub_author = u"holger krekel at merlinux eu"
epub_publisher = u"holger krekel at merlinux eu"
epub_copyright = u"2013, holger krekel et alii"
epub_title = "pytest"
epub_author = "holger krekel at merlinux eu"
epub_publisher = "holger krekel at merlinux eu"
epub_copyright = "2013, holger krekel et alii"

# The language of the text. It defaults to the language option
# or en if the language is not set.
Expand Down
1 change: 0 additions & 1 deletion doc/en/conftest.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
collect_ignore = ["conf.py"]
31 changes: 15 additions & 16 deletions doc/en/example/assertion/failure_demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import _pytest._code
import pytest
from pytest import raises
Expand All @@ -21,7 +20,7 @@ def test_generative(param1, param2):
assert param1 * 2 < param2


class TestFailing(object):
class TestFailing:
def test_simple(self):
def f():
return 42
Expand All @@ -41,7 +40,7 @@ def f():
assert not f()


class TestSpecialisedExplanations(object):
class TestSpecialisedExplanations:
def test_eq_text(self):
assert "spam" == "eggs"

Expand Down Expand Up @@ -101,7 +100,7 @@ def test_eq_dataclass(self):
from dataclasses import dataclass

@dataclass
class Foo(object):
class Foo:
a: int
b: str

Expand All @@ -113,7 +112,7 @@ def test_eq_attrs(self):
import attr

@attr.s
class Foo(object):
class Foo:
a = attr.ib()
b = attr.ib()

Expand All @@ -123,22 +122,22 @@ class Foo(object):


def test_attribute():
class Foo(object):
class Foo:
b = 1

i = Foo()
assert i.b == 2


def test_attribute_instance():
class Foo(object):
class Foo:
b = 1

assert Foo().b == 2


def test_attribute_failure():
class Foo(object):
class Foo:
def _get_b(self):
raise Exception("Failed to get attrib")

Expand All @@ -149,10 +148,10 @@ def _get_b(self):


def test_attribute_multiple():
class Foo(object):
class Foo:
b = 1

class Bar(object):
class Bar:
b = 2

assert Foo().b == Bar().b
Expand All @@ -162,7 +161,7 @@ def globf(x):
return x + 1


class TestRaises(object):
class TestRaises:
def test_raises(self):
s = "qwe"
raises(TypeError, int, s)
Expand Down Expand Up @@ -203,7 +202,7 @@ def test_dynamic_compile_shows_nicely():
module.foo()


class TestMoreErrors(object):
class TestMoreErrors:
def test_complex_error(self):
def f():
return 44
Expand Down Expand Up @@ -253,16 +252,16 @@ def test_try_finally(self):
x = 0


class TestCustomAssertMsg(object):
class TestCustomAssertMsg:
def test_single_line(self):
class A(object):
class A:
a = 1

b = 2
assert A.a == b, "A.a appears not to be b"

def test_multiline(self):
class A(object):
class A:
a = 1

b = 2
Expand All @@ -271,7 +270,7 @@ class A(object):
), "A.a appears not to be b\nor does not appear to be b\none of those"

def test_custom_repr(self):
class JSON(object):
class JSON:
a = 1

def __repr__(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import py

import pytest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
hello = "world"


Expand Down
1 change: 0 additions & 1 deletion doc/en/example/assertion/test_failures.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import py

failure_demo = py.path.local(__file__).dirpath("failure_demo.py")
Expand Down
3 changes: 1 addition & 2 deletions doc/en/example/assertion/test_setup_flow_example.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
def setup_module(module):
module.TestStateFullThing.classcount = 0


class TestStateFullThing(object):
class TestStateFullThing:
def setup_class(cls):
cls.classcount += 1

Expand Down
1 change: 0 additions & 1 deletion doc/en/example/conftest.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
collect_ignore = ["nonpython"]
3 changes: 1 addition & 2 deletions doc/en/example/costlysetup/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import pytest


Expand All @@ -9,7 +8,7 @@ def setup(request):
setup.finalize()


class CostlySetup(object):
class CostlySetup:
def __init__(self):
import time

Expand Down
1 change: 0 additions & 1 deletion doc/en/example/costlysetup/sub_a/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
#
1 change: 0 additions & 1 deletion doc/en/example/costlysetup/sub_a/test_quick.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# -*- coding: utf-8 -*-
def test_quick(setup):
pass
1 change: 0 additions & 1 deletion doc/en/example/costlysetup/sub_b/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
#
1 change: 0 additions & 1 deletion doc/en/example/costlysetup/sub_b/test_two.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
def test_something(setup):
assert setup.timecostly == 1

Expand Down
3 changes: 1 addition & 2 deletions doc/en/example/multipython.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
module containing a parametrized tests testing cross-python
serialization via the pickle module.
Expand All @@ -23,7 +22,7 @@ def python2(request, python1):
return Python(request.param, python1.picklefile)


class Python(object):
class Python:
def __init__(self, version, picklefile):
self.pythonpath = distutils.spawn.find_executable(version)
if not self.pythonpath:
Expand Down
3 changes: 1 addition & 2 deletions doc/en/example/nonpython/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# content of conftest.py
import pytest

Expand All @@ -19,7 +18,7 @@ def collect(self):

class YamlItem(pytest.Item):
def __init__(self, name, parent, spec):
super(YamlItem, self).__init__(name, parent)
super().__init__(name, parent)
self.spec = spec

def runtest(self):
Expand Down
1 change: 0 additions & 1 deletion doc/en/example/py2py3/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import sys

import pytest
Expand Down
1 change: 0 additions & 1 deletion doc/en/example/py2py3/test_py3.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
def test_exception_syntax():
try:
0 / 0
Expand Down
3 changes: 1 addition & 2 deletions doc/en/example/pythoncollection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# run this with $ pytest --collect-only test_collectonly.py
#

Expand All @@ -7,7 +6,7 @@ def test_function():
pass


class TestClass(object):
class TestClass:
def test_method(self):
pass

Expand Down
1 change: 0 additions & 1 deletion doc/en/example/xfail_demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import pytest

xfail = pytest.mark.xfail
Expand Down
2 changes: 0 additions & 2 deletions doc/en/writing_plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,6 @@ string value of ``Hello World!`` if we do not supply a value or ``Hello

.. code-block:: python

# -*- coding: utf-8 -*-

import pytest


Expand Down
1 change: 0 additions & 1 deletion extra/get_issues.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import json

import py
Expand Down
1 change: 0 additions & 1 deletion extra/setup-py.test/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import sys
from distutils.core import setup

Expand Down
1 change: 0 additions & 1 deletion scripts/release.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Invoke development tasks.
"""
Expand Down
Loading