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

pylint, isort and python 3 updates #534

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions ci/testdata/cython_test.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ that uses newtowns method to compute the square root of a number """

from cython cimport floating


cpdef sqrt(floating value):
# solve for the square root of value by finding the zeros of
# 'x * x - value = 0' using newtons meethod
Expand Down
6 changes: 3 additions & 3 deletions ci/update_python_test_versions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import requests
import pathlib
import re

import requests

_VERSIONS_URL = "https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json" # noqa

Expand All @@ -14,7 +14,7 @@ def get_github_python_versions():
versions_json = requests.get(_VERSIONS_URL).json()
raw_versions = [v["version"] for v in versions_json]
versions = []
for version_str in raw_versions:
for version_str in raw_versions:
if "-" in version_str and version_str != "3.11.0-beta.5":
continue

Expand All @@ -23,7 +23,7 @@ def get_github_python_versions():
# we don't support python 3.0/3.1/3.2 , and don't bother testing 3.3/3.4
continue

elif major == 2 and minor < 7:
if major == 2 and minor < 7:
# we don't test python support before 2.7
continue

Expand Down
6 changes: 3 additions & 3 deletions generate_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

def build_python(cpython_path, version):
# TODO: probably easier to use pyenv for this?
print("Compiling python %s from repo at %s" % (version, cpython_path))
print(f"Compiling python {version} from repo at {cpython_path}")
install_path = os.path.abspath(os.path.join(cpython_path, version))

ret = os.system(f"""
Expand Down Expand Up @@ -98,14 +98,14 @@ def calculate_pyruntime_offsets(cpython_path, version, configure=False):


def extract_bindings(cpython_path, version, configure=False):
print("Generating bindings for python %s from repo at %s" % (version, cpython_path))
print(f"Generating bindings for python {version} from repo at {cpython_path}")

ret = os.system(f"""
cd {cpython_path}
git checkout {version}

# need to run configure on the current branch to generate pyconfig.h sometimes
{("./configure prefix=" + os.path.abspath(os.path.join(cpython_path, version))) if configure else ""}
{("./configure refix=" + os.path.abspath(os.path.join(cpython_path, version))) if configure else ""}

cat Include/Python.h > bindgen_input.h
cat Include/frameobject.h >> bindgen_input.h
Expand Down
6 changes: 3 additions & 3 deletions tests/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

import json
import os
import re
import subprocess
import sys
import re
import tempfile
import unittest
from collections import defaultdict, namedtuple
from distutils.spawn import find_executable
from shutil import which

Frame = namedtuple("Frame", ["file", "name", "line", "col"])

# disable gil checks on windows - just rely on active
# (doesn't seem to be working quite right - TODO: investigate)
GIL = ["--gil"] if not sys.platform.startswith("win") else []
PYSPY = find_executable("py-spy")
PYSPY = which("py-spy")


class TestPyspy(unittest.TestCase):
Expand Down
5 changes: 3 additions & 2 deletions tests/scripts/subprocesses.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import time
import multiprocessing
import time


def target():
multiprocessing.freeze_support()
Expand All @@ -16,4 +17,4 @@ def main():

if __name__ == "__main__":
multiprocessing.freeze_support()
main()
main()
3 changes: 2 additions & 1 deletion tests/scripts/subprocesses_zombie_child.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import time
import multiprocessing
import time


def target():
pass
Expand Down
4 changes: 2 additions & 2 deletions tests/scripts/thread_names.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import time
import threading
import time


def main():
for i in range(10):
th = threading.Thread(target = lambda: time.sleep(10000))
th.name = "CustomThreadName-%s" % i
th.name = f"CustomThreadName-{i}"
th.start()
time.sleep(10000)

Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/thread_reuse.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import time
import threading
import time

while True:
th = threading.Thread(target = lambda: time.sleep(.5))
Expand Down
1 change: 1 addition & 0 deletions tests/scripts/unicode💩.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
import time


def function1(seconds):
time.sleep(seconds)

Expand Down