profile
viewpoint

buildbot/buildbot 4346

Python-based continuous integration testing framework; your pull requests are more than welcome!

rodrigc/anchore-engine 0

A service that analyzes docker images and applies user-defined acceptance policies to allow automated container image validation and certification

rodrigc/atf 0

Libraries to write tests in C, C++ and shell

rodrigc/atf-packaging 0

packaging files for ATF

rodrigc/automat 0

Self-service finite-state machines for the programmer on the go.

rodrigc/azure-cli 0

Command-line tools for Azure.

rodrigc/azure-sdk-for-go 0

Microsoft Azure SDK for Go

rodrigc/blueocean-plugin 0

Blue Ocean is a reboot of the Jenkins CI/CD User Experience

rodrigc/braid 0

Automation scripts for twistedmatrix.com

Pull request review commenttwisted/twisted

Allow @unittest.skipIf decorator to specify that a test class should be skipped

 def getSkip(self):         Return the skip reason set on this test, if any is set. Checks on the         instance first, then the class, then the module, then packages. As         soon as it finds something with a C{skip} attribute, returns that.+        If the C{skip} attribute does not exist, look for C{__unittest_skip__}+        and C{__unittest_skip_why__} attributes which are set by the standard+        library L{unittest.skip} function.         Returns L{None} if it cannot find anything. See L{TestCase} docstring         for more details.         """-        return util.acquireAttribute(self._parents, 'skip', None)+        skipReason = util.acquireAttribute(self._parents, 'skip', None)+        if skipReason is None:+            if getattr(self, "__unittest_skip__", None):+                skipReason = getattr(self, "__unittest_skip_why__", None)

You are reading the unittest code wrong. That's not how it behaves. For this example:

from unittest import TestCase
from unittest import skipIf, main

class TestStringMethods(TestCase):

    @skipIf(True, '')
    def test_upper(self):
        print("RAN test_upper")
        self.assertEqual('foo'.upper(), 'FOO')

    @skipIf(False, '')
    def test_isupper(self):
        print("RAN test_isupper")
        self.assertTrue('FOO'.isupper())
        self.assertFalse('Foo'.isupper())

    @skipIf(True, '')
    def test_split(self):
        print("RAN test_split")
        s = 'hello world'
        self.assertEqual(s.split(), ['hello', 'world'])
        # check that s.split fails when the separator is not a string
        with self.assertRaises(TypeError):
            s.split(2)


if __name__ == '__main__':
    main()

Only the first argument to skipIf is used for skipping. The second argument, even if it is an empty string, does not control whether skipping occurs or not.

rodrigc

comment created time in 15 hours

push eventtwisted/twisted

Craig Rodrigues

commit sha 00228c52f7dc9f03a25a6516f8cb91d6970748c8

Use unittest.skipIf decorator for skipping certain test functions. This reduces errors reported by mypy of the form: src/twisted/words/test/test_domish.py:193:9: error: "Callable[[ElementTests], Any]" has no attribute "skip" [attr-defined] test_addContentBytes.skip = (

view details

push time in 17 hours

push eventtwisted/twisted

Craig Rodrigues

commit sha a2795d1a47226f2d9ea7848f6f9bd8f312ea1a1f

Use unittest.skipIf decorator for skipping certain test functions. This reduces errors reported by mypy of the form: src/twisted/words/test/test_domish.py:193:9: error: "Callable[[ElementTests], Any]" has no attribute "skip" [attr-defined] test_addContentBytes.skip = (

view details

push time in 18 hours

push eventtwisted/twisted

Craig Rodrigues

commit sha f4b8f8a26278ed93c22248b6ee314f0fb156891c

Use unittest.skipIf decorator for skipping certain test functions. This reduces errors reported by mypy of the form: src/twisted/words/test/test_domish.py:193:9: error: "Callable[[ElementTests], Any]" has no attribute "skip" [attr-defined] test_addContentBytes.skip = (

view details

push time in a day

push eventtwisted/twisted

Craig Rodrigues

commit sha 2994361895d49d75f941ac64c11864cd38a4fe46

Add newsfragment

view details

Craig Rodrigues

commit sha 61ba5fe294b2f6ccba7409aaca3ddf125b8efcad

Always use sys.stdout.buffer which is always available on Python 3+

view details

Craig Rodrigues

commit sha 62d96144872780c7254393e49e03044aa360845e

Merge pull request #1268 from twisted/9823-rodrigc-mypy Always use sys.stdout.buffer which is always available on Python 3+ Author: rodrigc Reviewer: adiroiban, meejah Fixes: ticket:9823

view details

Craig Rodrigues

commit sha 24aaee1f201ab1ee56b8074f01a4592120c7b3df

Add newsfragment

view details

Craig Rodrigues

commit sha 04ece218a9f7bbeaa1faa37346317abbf37c5bd7

Add variable type annotations for mypy Eliminate some Python-2 only blocks of code

view details

Craig Rodrigues

commit sha 414d490bb7811fb7b55cf2cfbf71f7a8b8527485

Merge pull request #1271 from twisted/9827-rodrigc-mypy Add more type annotations Author: rodrigc Reviewer: wsanchez Fixes: ticket:9827

view details

Craig Rodrigues

commit sha 56903ea66eaa61e21f479deea923c26c36012310

Look for 'skip' or '__unittest_skip__' attributes when deciding to skip a test. The standard library unittest.skip function adds these attributes on objects which should be skipped by a test runner: __unittest_skip__ __unittest_skip_why__ This change allows trial to skip classes which are decorated with @unittest.skipIf. This behavior is consistent with the standard library unittest runner and pytest.

view details

Craig Rodrigues

commit sha 83d53c8f5039de6439b02753a74e62ce05b086a1

Add tests for skipping tests with trial

view details

Craig Rodrigues

commit sha b8d18aca684234ef726ed33afe77ed9026c09972

Add newsfragment

view details

Craig Rodrigues

commit sha 789da4ff689bca96da44def0c897cfdaceec2b96

Use the @skipIf decorator to skip certain test classes This reduces errors with mypy

view details

push time in 2 days

push eventtwisted/twisted

Craig Rodrigues

commit sha 2994361895d49d75f941ac64c11864cd38a4fe46

Add newsfragment

view details

Craig Rodrigues

commit sha 61ba5fe294b2f6ccba7409aaca3ddf125b8efcad

Always use sys.stdout.buffer which is always available on Python 3+

view details

Craig Rodrigues

commit sha 62d96144872780c7254393e49e03044aa360845e

Merge pull request #1268 from twisted/9823-rodrigc-mypy Always use sys.stdout.buffer which is always available on Python 3+ Author: rodrigc Reviewer: adiroiban, meejah Fixes: ticket:9823

view details

Craig Rodrigues

commit sha 24aaee1f201ab1ee56b8074f01a4592120c7b3df

Add newsfragment

view details

Craig Rodrigues

commit sha 04ece218a9f7bbeaa1faa37346317abbf37c5bd7

Add variable type annotations for mypy Eliminate some Python-2 only blocks of code

view details

Craig Rodrigues

commit sha 414d490bb7811fb7b55cf2cfbf71f7a8b8527485

Merge pull request #1271 from twisted/9827-rodrigc-mypy Add more type annotations Author: rodrigc Reviewer: wsanchez Fixes: ticket:9827

view details

Craig Rodrigues

commit sha 7681b556f034e8d466406a5e7e03182c719a6b94

Add newsfragment

view details

Craig Rodrigues

commit sha e2be9ebf43effa2d289b4ec0e564105f143f0468

Use unittest.skipIf decorator for skipping certain test functions. This reduces errors reported by mypy of the form: src/twisted/words/test/test_domish.py:193:9: error: "Callable[[ElementTests], Any]" has no attribute "skip" [attr-defined] test_addContentBytes.skip = (

view details

push time in 2 days

delete branch twisted/twisted

delete branch : 9827-rodrigc-mypy

delete time in 2 days

push eventtwisted/twisted

Craig Rodrigues

commit sha 24aaee1f201ab1ee56b8074f01a4592120c7b3df

Add newsfragment

view details

Craig Rodrigues

commit sha 04ece218a9f7bbeaa1faa37346317abbf37c5bd7

Add variable type annotations for mypy Eliminate some Python-2 only blocks of code

view details

Craig Rodrigues

commit sha 414d490bb7811fb7b55cf2cfbf71f7a8b8527485

Merge pull request #1271 from twisted/9827-rodrigc-mypy Add more type annotations Author: rodrigc Reviewer: wsanchez Fixes: ticket:9827

view details

push time in 2 days

PR merged twisted/twisted

Reviewers
Add more type annotations

https://twistedmatrix.com/trac/ticket/9827

Add some type annotations which eliminate mypy errors such as:

src/twisted/words/protocols/jabber/jid.py:108:1: error: Need type annotation for '__internJIDs' (hint: "__internJIDs: Dict[<type>, <type>] = ...")  [var-annotated]
    __internJIDs = {}
+444 -245

2 comments

72 changed files

rodrigc

pr closed time in 2 days

pull request commenttwisted/twisted

Add more type annotations

@wsanchez OK, I added Optional to all the places that you suggested.

rodrigc

comment created time in 2 days

push eventtwisted/twisted

Kyle Altendorf

commit sha 9646db406454def1d5d5ce0ac89e01941450567f

Merge altendky:9826-altendky-contextvars_backport_compatibility: Fix contextvars backport compatibility Author: altendky Reviewer: hawkowl Fixes: ticket:9826

view details

Glyph

commit sha e17604416eadc58e90f28806968e267a06c38909

Merge 9718-automat-3.8-baseline: Update automat dependency to 0.8.0 or greater Author: glyph Reviewer: hawkowl Fixes: ticket:9718

view details

Craig Rodrigues

commit sha 2994361895d49d75f941ac64c11864cd38a4fe46

Add newsfragment

view details

Craig Rodrigues

commit sha 61ba5fe294b2f6ccba7409aaca3ddf125b8efcad

Always use sys.stdout.buffer which is always available on Python 3+

view details

Craig Rodrigues

commit sha 62d96144872780c7254393e49e03044aa360845e

Merge pull request #1268 from twisted/9823-rodrigc-mypy Always use sys.stdout.buffer which is always available on Python 3+ Author: rodrigc Reviewer: adiroiban, meejah Fixes: ticket:9823

view details

Craig Rodrigues

commit sha 24aaee1f201ab1ee56b8074f01a4592120c7b3df

Add newsfragment

view details

Craig Rodrigues

commit sha 04ece218a9f7bbeaa1faa37346317abbf37c5bd7

Add variable type annotations for mypy Eliminate some Python-2 only blocks of code

view details

push time in 2 days

push eventrodrigc/kubespray

Craig Rodrigues

commit sha a1da8a7525250051e51008a1216c49860424dcdb

Rewrite download_hash in Python - Directly update the main.yml file with the new hashes.

view details

push time in 3 days

push eventrodrigc/kubespray

Craig Rodrigues

commit sha 63cb42c8ddbf2ff376a0c97af4f775b859bfc8c5

Rewrite download_hash in Python - Directly update the main.yml file with the new hashes.

view details

push time in 3 days

Pull request review commentkubernetes-sigs/kubespray

Rewrite download_hash in Python

+#!/usr/bin/env python3++# After a new version of Kubernetes has been released,+# run this script to update roles/download/defaults/main.yml+# with new hashes.++import hashlib+import sys++import requests+from ruamel.yaml import YAML++MAIN_YML = "../roles/download/defaults/main.yml"++def open_main_yaml():+    yaml = YAML()+    yaml.explicit_start = True+    yaml.preserve_quotes = True+    yaml.width = 4096++    with open(MAIN_YML, "r") as main_yml:+        data = yaml.load(main_yml)++    return data, yaml+++def download_hash(versions):+    architectures = ["arm", "arm64", "amd64"]+    downloads = ["kubelet", "kubectl", "kubeadm"]++    data, yaml = open_main_yaml()++    for download in downloads:+        checksum_name = f"{download}_checksums"+        for arch in architectures:+            for version in versions:+                url = f"https://storage.googleapis.com/kubernetes-release/release/{version}/bin/linux/{arch}/{download}"+                download_file = requests.get(url, allow_redirects=True)+                download_file.raise_for_status()+                sha256sum = hashlib.sha256(download_file.content).hexdigest()+                data[checksum_name][arch][version] = sha256sum++    with open(MAIN_YML, "w") as main_yml:+        yaml.dump(data, main_yml)+        print(f"\n\nUpdated {MAIN_YML}\n")+++def main(argv=None):+    if not argv:

OK, I added a usage() function which is called if no arguments are passed.

rodrigc

comment created time in 3 days

Pull request review commenttwisted/twisted

Add more type annotations

 import os import errno try:-    import fcntl+    import fcntl as _fcntl except ImportError:     fcntl = None+else:+    fcntl = _fcntl

How would you add type annotations for the return type of requireModule here: https://github.com/twisted/twisted/blob/4e42bf4928266b5135be6d66f1532d52317d8731/src/twisted/python/reflect.py#L179 ?

rodrigc

comment created time in 3 days

Pull request review commenttwisted/twisted

Add more type annotations

 import os import errno try:-    import fcntl+    import fcntl as _fcntl except ImportError:     fcntl = None+else:+    fcntl = _fcntl

Well if I do this from the repl:

>>> import fcntl
>>> type(fcntl)
<class 'module'>

I couldn't figure out a way to add an annotation for class 'module'

rodrigc

comment created time in 3 days

Pull request review commenttwisted/twisted

Add more type annotations

 import os import errno try:-    import fcntl+    import fcntl as _fcntl except ImportError:     fcntl = None+else:+    fcntl = _fcntl

I don't know how to specify type hints for a module. I've looked for examples and asked on https://gitter.im/python/typing but haven't found an example.

rodrigc

comment created time in 3 days

Pull request review commenttwisted/twisted

Add more type annotations

 import os import errno try:-    import fcntl+    import fcntl as _fcntl except ImportError:     fcntl = None+else:+    fcntl = _fcntl

I took this pattern from here: https://github.com/python/mypy/issues/1297#issuecomment-508593494

I couldn't figure out a cleaner way to eliminate the mypy error, other than doing:

try:
    import fcntl
except ImportError:
    fcntl = None    # type: ignore

Maybe it would be better to do this?

from twisted.python.reflect import requireModule

fcntl = requireModule("fcntl")
rodrigc

comment created time in 3 days

delete branch twisted/twisted

delete branch : 9823-rodrigc-mypy

delete time in 3 days

push eventtwisted/twisted

Craig Rodrigues

commit sha 2994361895d49d75f941ac64c11864cd38a4fe46

Add newsfragment

view details

Craig Rodrigues

commit sha 61ba5fe294b2f6ccba7409aaca3ddf125b8efcad

Always use sys.stdout.buffer which is always available on Python 3+

view details

Craig Rodrigues

commit sha 62d96144872780c7254393e49e03044aa360845e

Merge pull request #1268 from twisted/9823-rodrigc-mypy Always use sys.stdout.buffer which is always available on Python 3+ Author: rodrigc Reviewer: adiroiban, meejah Fixes: ticket:9823

view details

push time in 3 days

PR merged twisted/twisted

Reviewers
Always use sys.stdout.buffer which is always available on Python 3+

https://twistedmatrix.com/trac/ticket/9823

Fix mypy errors like:

src/twisted/test/process_stdinreader.py:20:14: error: Incompatible types in assignment (expression has type "TextIO", variable has type "BinaryIO")  [assignment]
        stdout = sys.stdout
+24 -54

1 comment

5 changed files

rodrigc

pr closed time in 3 days

push eventtwisted/twisted

Craig Rodrigues

commit sha af5861fd40aa2659719a3f8051161ddbf61bf3f3

Add newsfragment

view details

Craig Rodrigues

commit sha 2e058fb9d928238c636882b226b134ece9186247

Use @classmethod decorator

view details

Craig Rodrigues

commit sha adbc8bb478b901ace997488690561d9ef864b2c4

Replace bare except with a catch of BaseException This appeases pycodestyle

view details

Craig Rodrigues

commit sha d3c96b2eac2dce12ebee0bfa8dd15fc48f62e0cc

Merge pull request #1267 from twisted/9820-rodrigc-mypy Use @classmethod decorator, to eliminate mypy warnings Author: rodrigc Reviewer: adiroiban Fixes: ticket:9820

view details

Kyle Altendorf

commit sha 9646db406454def1d5d5ce0ac89e01941450567f

Merge altendky:9826-altendky-contextvars_backport_compatibility: Fix contextvars backport compatibility Author: altendky Reviewer: hawkowl Fixes: ticket:9826

view details

Glyph

commit sha e17604416eadc58e90f28806968e267a06c38909

Merge 9718-automat-3.8-baseline: Update automat dependency to 0.8.0 or greater Author: glyph Reviewer: hawkowl Fixes: ticket:9718

view details

Craig Rodrigues

commit sha 2994361895d49d75f941ac64c11864cd38a4fe46

Add newsfragment

view details

Craig Rodrigues

commit sha 61ba5fe294b2f6ccba7409aaca3ddf125b8efcad

Always use sys.stdout.buffer which is always available on Python 3+

view details

push time in 3 days

PR opened kubernetes-sigs/kubespray

Fix indentation in a few places so file can be round-tripped more easily with the Python ruamel.yml library

What type of PR is this? /kind cleanup

What this PR does / why we need it:

This fixes a few places so that we can more easily round-trip this file with the Python ruamel.yml library. This PR is related to (but not required by): https://github.com/kubernetes-sigs/kubespray/pull/5995

Does this PR introduce a user-facing change?:

NONE
+62 -62

0 comment

1 changed file

pr created time in 4 days

create barnchrodrigc/kubespray

branch : fix-indentation

created branch time in 4 days

PR closed kubernetes-sigs/kubespray

Reviewers
Add hashes for kubernetes 1.18.3 cncf-cla: yes kind/feature needs-ok-to-test size/XS

What type of PR is this? /kind feature

What this PR does / why we need it:

Add hashes for Kubernetes 1.18.3

Does this PR introduce a user-facing change?:

NONE
+9 -0

5 comments

1 changed file

rodrigc

pr closed time in 4 days

pull request commentkubernetes-sigs/kubespray

Add hashes for kubernetes 1.18.3

Superseded by https://github.com/kubernetes-sigs/kubespray/pull/6173

rodrigc

comment created time in 4 days

push eventrodrigc/kubespray

Craig Rodrigues

commit sha a55925b2f9692927ed3c0d3f946dcf935b337eb0

Rewrite download_hash in Python - Directly update the main.yml file with the new hashes.

view details

push time in 4 days

push eventrodrigc/kubespray

Craig Rodrigues

commit sha 8c6f2fde83f9cf234d07339c0a8344b8c000ba4c

Add hashes for 1.18.3

view details

push time in 4 days

pull request commentkubernetes-sigs/kubespray

Add hashes for kubernetes 1.18.3

/assign riverzhang

rodrigc

comment created time in 4 days

PR opened kubernetes-sigs/kubespray

Add hashes for kubernetes 1.18.3

What type of PR is this? /kind feature

What this PR does / why we need it:

Add hashes for Kubernetes 1.18.3

Does this PR introduce a user-facing change?:

NONE
+9 -1

0 comment

1 changed file

pr created time in 4 days

create barnchrodrigc/kubespray

branch : k8s-1.18.3

created branch time in 4 days

pull request commentkubernetes-sigs/kubespray

Rewrite download_hash in Python

@floryut OK, I changed this PR to not delete the old download_hash script

rodrigc

comment created time in 4 days

push eventrodrigc/kubespray

Victor Morales

commit sha 2bec26dba50898ba335c4a12f5c4e22bb1ea4486

Add proxy support to CRI-O service (#4607) * Add proxy support to CRI-O service The crio.service requires proxy environment variables when it's deployed behind a corporated network. This change creates a systemd configuration file when the proxy variables are defined. * Remove unnecesary crio's tasks

view details

Florian Ruynat

commit sha ca45d5ffbe9291ec96be75d9330c00af99fd1525

Fix retries keyword missing until instruction (#5989)

view details

Kenichi Omichi

commit sha 15be42abfd8562e9cec6cb2515879c3f14373f30

Update path of all.yml on Azure README (#5993) cloud_provider option exists in ./inventory/sample/group_vars/all/all.yml In addition, the quick start shows to create configuration by copying ./inventory/sample. So this updates path of all.yml for fitting the above.

view details

Maxime Guyot

commit sha 8939196f0d66dae123e60d0c9f70ddf31a79772a

Verify apiserver version in CI (#5918)

view details

Florian Ruynat

commit sha 1c187e9729c6bfd5edce0918c3e7befe19712043

Downgrade coredns to 1.6.5 due to upgrade errors while migrating coredns configmap (Corefile) (#5960)

view details

Maxime Guyot

commit sha 09bccc97bab30673e810ed893df19936346aa7ea

Add CRI-O CI (#5460)

view details

Florent Monbillard

commit sha d7df5778982ed0b0dd46e80407109119f6483844

k8s-dns-node-cache 1.15.12 was released (#5999)

view details

Florian Ruynat

commit sha b8cd9403df0fb96d402f656665abdae9be9eb4aa

Fix nginx template missing latest changes (#6000)

view details

spaced

commit sha b0484fe3e5cc32b16134e139bba2cc5d2b40ffcf

Ubuntu crio repo (#5994) * declare kubic repo for ubuntu * do not install crictl twice * move fedora repo modular tasks to crio_repo file * move centos repo tasks to crio_repo * declare crio version matrix for ubuntu * update documentation crio support for ubuntu

view details

Sergey

commit sha aead0e3a6954fdf47c733b1a514cb4aa678b2f99

bump minimal ansible version to 2.8.0 (#5984) * bump minimal ansible version to 2.8.0 * check ansible version in separate playbook

view details

Maxime Guyot

commit sha b44f7957d52b4637ab6637adda3b82aa06ff458e

Update CI matrix (#6010)

view details

Maxime Guyot

commit sha c6d91b89d7587d389c36c250fc859a9a3bd2f3ba

Update CONTRIBUTING.md (#6012)

view details

spaced

commit sha cf1566e8ed4c04fd82a848bdf5fe3545fe719443

Centos, debian and fedora CRI-O repo (#6008) * replace removed repo with kubic repository for centos 7 * add crio configuration for centos8 * add crio configurations for debian * use correct crio version for fedora * simplify calulation of required crio version - gives possibility to overwrite * change default path for runc * change default for seccomp path * change default for conmon

view details

Maxime Guyot

commit sha 6674be25725529acd520193be9ee76b29de87cae

Cleanup Vagrant VMs before molecule and vagrant CI (#6009)

view details

Florian Ruynat

commit sha 299e35ebe4a69f133dba74aeea090504f2240bbc

Cleanup unused/erroneous variables (#6003)

view details

Sergey

commit sha 69603aed34c79d03f9f8ce1fe975f89314fe7c7b

add strategy mitogen_linear when installed mitogen (#5985) * add strategy mitogen_linear when installed mitogen * add small docs Rename playbook file The raw action executes as a regular Mitogen connection, which requires Python on the target, so add strategy: linear to bootstrap-os role playbook. * add mitogen to CI test fix typo * enable mitogen test on deploy-part1 tests change version from master to release download tar.gz archive * run all CI tests with mitogen * disable mitogen with upgrade CI tests * enable mitogen on CI tests via env vars * disable mitogen on CI test by default, enable on some different OS * disable mitogen CI test on centos8 (get error /usr/bin/python: No such file or directory)

view details

Pasquale Toscano

commit sha 3d5988577a6ac3f51a2b9859d14d1b44249eb6ca

Support Cilium from version 1.5 (#6006)

view details

Joel Seguillon

commit sha 98e7a07fbae671c3651e3c687398356362ebb5cd

bump to dashboard 2.0.0 with metrics scrapper support (#5821) * bump to dashboard 2.0 rc6 with metrics scrapper * fix missing yaml seperator making Replicaset complaining about missing ServiceAccount * unwanted legay gross hack forgot to remove before * no need namespace on CrBinding * bump to 2.0.0 release * remove dashboard_metrics_scrapper_enabled

view details

Samuel Liu

commit sha d8345c5eae473d80aea34aebf7692609dc8c06c6

MetalLB IP address range extension (#6023) * MetalLB IP address range extension * MetalLB IP address range extension

view details

Qasim Sarfraz

commit sha 52edd4c9bc5e32842253ee7d1c13d88d9466afde

Fix liveness probe for cilium operator (#6016)

view details

push time in 4 days

Pull request review commenttwisted/twisted

Allow @unittest.skipIf decorator to specify that a test class should be skipped

 def getSkip(self):         Return the skip reason set on this test, if any is set. Checks on the         instance first, then the class, then the module, then packages. As         soon as it finds something with a C{skip} attribute, returns that.+        If the C{skip} attribute does not exist, look for C{__unittest_skip__}+        and C{__unittest_skip_why__} attributes which are set by the standard+        library L{unittest.skip} function.         Returns L{None} if it cannot find anything. See L{TestCase} docstring         for more details.         """-        return util.acquireAttribute(self._parents, 'skip', None)+        skipReason = util.acquireAttribute(self._parents, 'skip', None)+        if skipReason is None:+            if getattr(self, "__unittest_skip__", None):+                skipReason = getattr(self, "__unittest_skip_why__", None)

I changed the implementation here slightly to match what was done in pytest.

rodrigc

comment created time in 4 days

Pull request review commenttwisted/twisted

Allow @unittest.skipIf decorator to specify that a test class should be skipped

   -+@skipIf(None in (unix, cryptography, pyasn1,+                 interfaces.IReactorProcess(reactor, None)),+        "don't run w/o spawnProcess or cryptography or pyasn1")

OK I changed this condition by using a variable.

rodrigc

comment created time in 4 days

push eventtwisted/twisted

Kyle Altendorf

commit sha 9646db406454def1d5d5ce0ac89e01941450567f

Merge altendky:9826-altendky-contextvars_backport_compatibility: Fix contextvars backport compatibility Author: altendky Reviewer: hawkowl Fixes: ticket:9826

view details

Glyph

commit sha e17604416eadc58e90f28806968e267a06c38909

Merge 9718-automat-3.8-baseline: Update automat dependency to 0.8.0 or greater Author: glyph Reviewer: hawkowl Fixes: ticket:9718

view details

Craig Rodrigues

commit sha c9eab8d302e950b7c7a5208662cb3beee1332c9a

Look for 'skip' or '__unittest_skip__' attributes when deciding to skip a test. The standard library unittest.skip function adds these attributes on objects which should be skipped by a test runner: __unittest_skip__ __unittest_skip_why__ This change allows trial to skip classes which are decorated with @unittest.skipIf. This behavior is consistent with the standard library unittest runner and pytest.

view details

Craig Rodrigues

commit sha 3249e669cf7ffa03253af42c7fdd02cd4179601b

Add tests for skipping tests with trial

view details

Craig Rodrigues

commit sha cb9b7578f77d309a461d87457010add3583dad49

Add newsfragment

view details

Craig Rodrigues

commit sha 7834d1d1932685e278e23ca5dcf0c1747f8a6939

Use the @skipIf decorator to skip certain test classes This reduces errors with mypy

view details

push time in 4 days

Pull request review commenttwisted/twisted

Allow @unittest.skipIf decorator to specify that a test class should be skipped

 def getSkip(self):         Return the skip reason set on this test, if any is set. Checks on the         instance first, then the class, then the module, then packages. As         soon as it finds something with a C{skip} attribute, returns that.+        If the C{skip} attribute does not exist, look for C{__unittest_skip__}+        and C{__unittest_skip_why__} attributes which are set by the standard+        library L{unittest.skip} function.         Returns L{None} if it cannot find anything. See L{TestCase} docstring         for more details.         """-        return util.acquireAttribute(self._parents, 'skip', None)+        skipReason = util.acquireAttribute(self._parents, 'skip', None)+        if skipReason is None:+            if getattr(self, "__unittest_skip__", None):+                skipReason = getattr(self, "__unittest_skip_why__", None)

You are misreading unittest. __unittest_skip__ is a boolean value, and __unittest_skip_why__ is a string value. Look at the pytest implementation as well.

rodrigc

comment created time in 4 days

push eventtwisted/twisted

Craig Rodrigues

commit sha af5861fd40aa2659719a3f8051161ddbf61bf3f3

Add newsfragment

view details

Craig Rodrigues

commit sha 2e058fb9d928238c636882b226b134ece9186247

Use @classmethod decorator

view details

Craig Rodrigues

commit sha adbc8bb478b901ace997488690561d9ef864b2c4

Replace bare except with a catch of BaseException This appeases pycodestyle

view details

Craig Rodrigues

commit sha d3c96b2eac2dce12ebee0bfa8dd15fc48f62e0cc

Merge pull request #1267 from twisted/9820-rodrigc-mypy Use @classmethod decorator, to eliminate mypy warnings Author: rodrigc Reviewer: adiroiban Fixes: ticket:9820

view details

Kyle Altendorf

commit sha 9646db406454def1d5d5ce0ac89e01941450567f

Merge altendky:9826-altendky-contextvars_backport_compatibility: Fix contextvars backport compatibility Author: altendky Reviewer: hawkowl Fixes: ticket:9826

view details

Glyph

commit sha e17604416eadc58e90f28806968e267a06c38909

Merge 9718-automat-3.8-baseline: Update automat dependency to 0.8.0 or greater Author: glyph Reviewer: hawkowl Fixes: ticket:9718

view details

Craig Rodrigues

commit sha e82a69ae7a5338868cec943fef509d1183695719

Add newsfragment

view details

Craig Rodrigues

commit sha 5bd569da3ff29295fc62b2bca5ba51b4f5f3cd53

Use unittest.skipIf decorator for skipping certain test functions. This reduces errors reported by mypy of the form: src/twisted/words/test/test_domish.py:193:9: error: "Callable[[ElementTests], Any]" has no attribute "skip" [attr-defined] test_addContentBytes.skip = (

view details

push time in 4 days

Pull request review commenttwisted/twisted

Allow @unittest.skipIf decorator to specify that a test class should be skipped

 def getSkip(self):         Return the skip reason set on this test, if any is set. Checks on the         instance first, then the class, then the module, then packages. As         soon as it finds something with a C{skip} attribute, returns that.+        If the C{skip} attribute does not exist, look for C{__unittest_skip__}+        and C{__unittest_skip_why__} attributes which are set by the standard+        library L{unittest.skip} function.         Returns L{None} if it cannot find anything. See L{TestCase} docstring         for more details.         """-        return util.acquireAttribute(self._parents, 'skip', None)+        skipReason = util.acquireAttribute(self._parents, 'skip', None)+        if skipReason is None:+            if getattr(self, "__unittest_skip__", None):+                skipReason = getattr(self, "__unittest_skip_why__", None)

I implemented it like that to be consistent with the behavior in

  • unittest: https://github.com/python/cpython/blob/515fce4fc4bb0d2db97b17df275cf90640017f56/Lib/unittest/case.py#L569
  • pytest: https://github.com/pytest-dev/pytest/blob/952762207a2de76bf2eb254dee16f3b53d79a77b/src/_pytest/unittest.py#L92
rodrigc

comment created time in 5 days

Pull request review commenttwisted/twisted

Allow @unittest.skipIf decorator to specify that a test class should be skipped

 def test_negotiationFailedByClosing(self):         # reasonable.         self.assertFailure(d, error.PeerVerifyError) -    skip = skipSSL

skipSSL is still used in this file. I didn't remove it here, because I have a separate PR where I used @skipIf to convert functions: https://github.com/twisted/twisted/pull/1264

rodrigc

comment created time in 5 days

pull request commentjenkinsci/jira-trigger-plugin

JENKINS-58987 Update dependency to jira-rest-java-client-core:5.2.1

@asekra This PR needs more work to make all the tests pass. I'm not familiar enough with the code, and I don't actively use this plugin, so would not some help from interested contributors.

rodrigc

comment created time in 11 days

pull request commenttwisted/twisted

Always use sys.stdout.buffer which is always available on Python 3+

mypy complains on that line because msvcrt can only be imported on Windows. So in that case mypy doesn't have enough information to know that setmode is part of the msvcrt module, and thus emits an error. There is no other clean way to silence this error, other than putting this comment to turn off this particular error on this line.

rodrigc

comment created time in 11 days

PR opened twisted/twisted

Allow @unittest.skipIf decorator to specify that a test class should be skipped

https://twistedmatrix.com/trac/ticket/9829

+214 -118

0 comment

15 changed files

pr created time in 11 days

create barnchtwisted/twisted

branch : 9829-rodrigc-trial

created branch time in 11 days

pull request commenttwisted/twisted

Add more type annotations

This PR eliminates about 200 errors from mypy. There is still a ways to go before turning mypy on by default as part of CI for Twisted, but we are getting closer...

rodrigc

comment created time in 12 days

push eventtwisted/twisted

Craig Rodrigues

commit sha e3689ba9a80aba11b5b75d6b3984bb517a92beae

Add variable type annotations for mypy Eliminate some Python-2 only blocks of code

view details

push time in 12 days

push eventtwisted/twisted

Craig Rodrigues

commit sha d7463406d9e02ff19e3fe0384dfef619095d967f

Add variable type annotations for mypy Eliminate some Python-2 only blocks of code

view details

push time in 12 days

push eventtwisted/twisted

Craig Rodrigues

commit sha 9022f6657c062347addeaf8fe8b3c71e271fad39

Add variable type annotations for mypy Eliminate some Python-2 only blocks of code

view details

push time in 12 days

push eventtwisted/twisted

Craig Rodrigues

commit sha 5d1a2a7080975c4de768fc421ba2a89c43e8aef2

Add variable type annotations for mypy Eliminate some Python-2 only blocks of code

view details

push time in 12 days

push eventtwisted/twisted

Craig Rodrigues

commit sha 424491c51dcc57246e74f4162622fe4c1f956f2f

Add variable type annotations for mypy Eliminate some Python-2 only blocks of code

view details

push time in 12 days

push eventtwisted/twisted

Craig Rodrigues

commit sha 0184a3275a065afddb69b008dfe5527cd1f148d1

Add variable type annotations for mypy Eliminate some Python-2 only blocks of code

view details

push time in 12 days

PR opened twisted/twisted

Add more type annotations

https://twistedmatrix.com/trac/ticket/9827

Add some type annotations which eliminate mypy errors such as:

src/twisted/words/protocols/jabber/jid.py:108:1: error: Need type annotation for '__internJIDs' (hint: "__internJIDs: Dict[<type>, <type>] = ...")  [var-annotated]
    __internJIDs = {}
+424 -241

0 comment

72 changed files

pr created time in 13 days

create barnchtwisted/twisted

branch : 9827-rodrigc-mypy

created branch time in 13 days

push eventtwisted/twisted

Craig Rodrigues

commit sha af5861fd40aa2659719a3f8051161ddbf61bf3f3

Add newsfragment

view details

Craig Rodrigues

commit sha 2e058fb9d928238c636882b226b134ece9186247

Use @classmethod decorator

view details

Craig Rodrigues

commit sha adbc8bb478b901ace997488690561d9ef864b2c4

Replace bare except with a catch of BaseException This appeases pycodestyle

view details

Craig Rodrigues

commit sha d3c96b2eac2dce12ebee0bfa8dd15fc48f62e0cc

Merge pull request #1267 from twisted/9820-rodrigc-mypy Use @classmethod decorator, to eliminate mypy warnings Author: rodrigc Reviewer: adiroiban Fixes: ticket:9820

view details

push time in 14 days

delete branch twisted/twisted

delete branch : 9820-rodrigc-mypy

delete time in 14 days

PR merged twisted/twisted

Reviewers
Use @classmethod decorator, to eliminate mypy warnings

https://twistedmatrix.com/trac/ticket/9820

This eliminates a bunch of mypy errors such as:

src/twisted/protocols/amp.py:1924:21: error: Incompatible types in assignment (expression has type "classmethod", variable has type "Callable[[Command, Any, Any], Any]")
 [assignment]
        parseResponse = classmethod(parseResponse)
+30 -28

0 comment

11 changed files

rodrigc

pr closed time in 14 days

push eventtwisted/twisted

Craig Rodrigues

commit sha a3726d9816dc153b07dde8bf467b86ea8d797038

Always use sys.stdout.buffer which is always available on Python 3+

view details

push time in 14 days

PR opened twisted/twisted

Always use sys.stdout.buffer which is always available on Python 3+

https://twistedmatrix.com/trac/ticket/9823

Fix mypy errors like:

src/twisted/test/process_stdinreader.py:20:14: error: Incompatible types in assignment (expression has type "TextIO", variable has type "BinaryIO")  [assignment]
        stdout = sys.stdout
+24 -54

0 comment

5 changed files

pr created time in 14 days

create barnchtwisted/twisted

branch : 9823-rodrigc-mypy

created branch time in 14 days

push eventtwisted/twisted

Craig Rodrigues

commit sha adbc8bb478b901ace997488690561d9ef864b2c4

Replace bare except with a catch of BaseException This appeases pycodestyle

view details

push time in 14 days

PR opened twisted/twisted

Reviewers
Use @classmethod decorator, to eliminate mypy warnings

https://twistedmatrix.com/trac/ticket/9820

This eliminates a bunch of mypy errors such as:

src/twisted/protocols/amp.py:1924:21: error: Incompatible types in assignment (expression has type "classmethod", variable has type "Callable[[Command, Any, Any], Any]")
 [assignment]
        parseResponse = classmethod(parseResponse)
+26 -26

0 comment

11 changed files

pr created time in 15 days

create barnchtwisted/twisted

branch : 9820-rodrigc-mypy

created branch time in 15 days

push eventrodrigc/anchore-engine

Craig Rodrigues

commit sha 1c34171481f60e93e27c3ef38580247b08741547

Add pointer to database upgrade docs when database out-of-version errors are logged Signed-off-by: Craig Rodrigues <rodrigc@crodrigues.org>

view details

push time in 17 days

Pull request review commentanchore/anchore-engine

Add pointer to database upgrade docs when database out-of-version errors are logged

 def start(services, auto_upgrade, anchore_module, skip_config_validate, skip_db_                             logger.warn(                                 "this version of anchore-engine requires the anchore DB version ({}) but we discovered anchore DB version ({}) in the running DB - it is safe to run the upgrade while seeing this message - will retry for {} more seconds.".format(                                     str(code_versions['db_version']), str(db_versions['db_version']), str(max_timeout - int(time.time() - timer))))+                            logger.warn("See: https://docs.anchore.com/current/docs/engine/engine_installation/upgrade/#advanced--manual-upgrade-procedure")

@zhill OK I removed it

rodrigc

comment created time in 17 days

push eventrodrigc/anchore-engine

Daniel Nurmi

commit sha af589b615afd53ffbce7094073257f17b306991f

add no-auto-upgrade flag to anchore manager and upgrade handler Signed-off-by: Daniel Nurmi <nurmi@anchore.com>

view details

Alfredo Deza

commit sha 40a1a42620a6546a2b6a6fc6465cef8fe5942ce0

remove unnecessary parens from statements Signed-off-by: Alfredo Deza <adeza@anchore.com>

view details

Alfredo Deza

commit sha 8728ba0377b106d2d50db805e8e8be44d424a69a

run linting in circleci Signed-off-by: Alfredo Deza <adeza@anchore.com>

view details

Alfredo Deza

commit sha 470de05a5016288e33a46cdd2f0155eb74e865da

lint: enable pylint with C0325 checks only Signed-off-by: Alfredo Deza <adeza@anchore.com>

view details

Zach Hill

commit sha 406b60ecac44a1022af4235981358182313f3702

Merge pull request #433 from anchore/dev/nurmi/noautoupdate Add ability to run services without auto-upgrade to enable more flexible upgrade flows

view details

Zach Hill

commit sha 0b6dea8c56e0f1e7e6ae4937aa87410af9e47f14

Removes docker-compose.yaml from inside the image via the Dockerfile. Reflects change to use docs site for proper quickstart docker-compose.yaml Signed-off-by: Zach Hill <zach@anchore.com>

view details

Zach Hill

commit sha dc4bb8d72b137dad940b328ca5ccd890a9924ef3

Update docker-compose to be docker-compose-dev.yaml to make its purpose clear Updates README to point to docs for quickstart docker-compose.yaml for released versions. Signed-off-by: Zach Hill <zach@anchore.com>

view details

Zach Hill

commit sha 5eaebe817ac2a97f6db80e50ef5b705b22eccb63

Fix missed anchore-db ref in compose Signed-off-by: Zach Hill <zach@anchore.com>

view details

Zach Hill

commit sha ab71540e621cbccace6b3a0f404cfea246d27566

Merge pull request #434 from anchore/compose_cleanup Compose cleanup

view details

Zach Hill

commit sha 448295ac2715f8d4f3311b738e12906bcc584e79

Update prometheus and swaggerui config examples with service names matching new docker-compose layout Signed-off-by: Zach Hill <zach@anchore.com>

view details

Zach Hill

commit sha 293320b2265e5e9aecf798d18d38205b122fd15b

Merge pull request #436 from anchore/update_prometheus_swaggerui_configs Update prometheus and swaggerui config examples with simpler service names

view details

Brady Todhunter

commit sha 00ac4a759f0d0a802784941e7385cabfec887428

version bump to v0.7.1 (#437) Signed-off-by: Brady Todhunter <bradyt@anchore.com>

view details

Alfredo Deza

commit sha ca2df6185a82ca89fcde47a13bec83f9359c2d6b

update on supported packages and OSs Signed-off-by: Alfredo Deza <adeza@anchore.com>

view details

Zach Hill

commit sha 79631ba90fef75731dc555f09c152398907df316

Merge pull request #440 from anchore/readme-updates update on supported packages and OSs

view details

Zach Hill

commit sha 6a60d72af3fc8a913b27b911c2595afc2da67136

Add 0.7.1 to changelog Signed-off-by: Zach Hill <zach@anchore.com>

view details

Zach Hill

commit sha a9071caff45a173fa8523ce37150fcfa1b83edd3

Fix typo in changelog with empty Removed line Signed-off-by: Zach Hill <zach@anchore.com>

view details

Zach Hill

commit sha 39e68f3218419151188f49d047fbe9ebd89f01c7

Merge pull request #441 from zhill/0.7.1-changelog Add 0.7.1 to changelog

view details

Alex Goodman

commit sha acb3a837e7dd7bd38a0295a07cd25abc779cb0f8

add licenses field to image content response Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

view details

Alex Goodman

commit sha b8383d14c1329553f024ad13de7392f05114be20

added docker_history/dockerfile/manifest content response tests Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

view details

Zach Hill

commit sha 78b23d7e8f007005c070673405b5e23730a660e0

Merge pull request #373 from anchore/issue-366-C0325 lint: removes unnecesary use of parens on statements

view details

push time in 17 days

push eventtwisted/twisted

Craig Rodrigues

commit sha 1e43d90f837ed40322f3b70c1f4b82093531f621

Use @classmethod decorator for makeTestCaseClasses() - Fix some pyflakes/pylint errors. - Add some type annotations to appease mypy

view details

Craig Rodrigues

commit sha a123fda3084605e04151101ea460010f9b513734

Add newsfragment

view details

Craig Rodrigues

commit sha e4989c3fc71ec690417ba18a9a39ce5bf1c53d5b

Change to BaseException

view details

Craig Rodrigues

commit sha 98769fe875744983615562035ca40f400e0756cf

ReactorBuilder must be in quotes in the annotation for makeTestCaseClasses. See: https://mypy.readthedocs.io/en/stable/kinds_of_types.html#class-name-forward-references

view details

Craig Rodrigues

commit sha a54deeb1eb1acbffc7e337d3891baf40119eef66

Rework conditional import to work with mypy

view details

Craig Rodrigues

commit sha 010e7447cd782ba40e375d443ad24cef411bffec

Turn off specific mypy errors on this line

view details

Craig Rodrigues

commit sha 79a26b0aa4b1b81b46cc64d203644b35e455e46b

Merge pull request #1261 from twisted/9811-rodrigc-mypy Fix mypy error: Too few arguments to "makeTestCaseClasses" Author: rodrigc Reviewer: glyph Fixes: ticket:9811

view details

Craig Rodrigues

commit sha 4721e1cff3969f0a6056ad98cbea1b7a2c5bb81f

Add newsfragment

view details

Craig Rodrigues

commit sha f6225553fb7e1bc34c1ed0fd6098bad6e71f9781

Use unittest.skipIf decorator for skipping certain test functions. This reduces errors reported by mypy of the form: src/twisted/words/test/test_domish.py:193:9: error: "Callable[[ElementTests], Any]" has no attribute "skip" [attr-defined] test_addContentBytes.skip = (

view details

push time in 17 days

delete branch twisted/twisted

delete branch : 9811-rodrigc-mypy

delete time in 17 days

push eventtwisted/twisted

Craig Rodrigues

commit sha 1e43d90f837ed40322f3b70c1f4b82093531f621

Use @classmethod decorator for makeTestCaseClasses() - Fix some pyflakes/pylint errors. - Add some type annotations to appease mypy

view details

Craig Rodrigues

commit sha a123fda3084605e04151101ea460010f9b513734

Add newsfragment

view details

Craig Rodrigues

commit sha e4989c3fc71ec690417ba18a9a39ce5bf1c53d5b

Change to BaseException

view details

Craig Rodrigues

commit sha 98769fe875744983615562035ca40f400e0756cf

ReactorBuilder must be in quotes in the annotation for makeTestCaseClasses. See: https://mypy.readthedocs.io/en/stable/kinds_of_types.html#class-name-forward-references

view details

Craig Rodrigues

commit sha a54deeb1eb1acbffc7e337d3891baf40119eef66

Rework conditional import to work with mypy

view details

Craig Rodrigues

commit sha 010e7447cd782ba40e375d443ad24cef411bffec

Turn off specific mypy errors on this line

view details

Craig Rodrigues

commit sha 79a26b0aa4b1b81b46cc64d203644b35e455e46b

Merge pull request #1261 from twisted/9811-rodrigc-mypy Fix mypy error: Too few arguments to "makeTestCaseClasses" Author: rodrigc Reviewer: glyph Fixes: ticket:9811

view details

push time in 17 days

PR merged twisted/twisted

Reviewers
Fix mypy error: Too few arguments to "makeTestCaseClasses"

https://twistedmatrix.com/trac/ticket/9811

+23 -15

1 comment

2 changed files

rodrigc

pr closed time in 17 days

push eventtwisted/twisted

Craig Rodrigues

commit sha 010e7447cd782ba40e375d443ad24cef411bffec

Turn off specific mypy errors on this line

view details

push time in 17 days

push eventtwisted/twisted

Craig Rodrigues

commit sha e4989c3fc71ec690417ba18a9a39ce5bf1c53d5b

Change to BaseException

view details

Craig Rodrigues

commit sha 98769fe875744983615562035ca40f400e0756cf

ReactorBuilder must be in quotes in the annotation for makeTestCaseClasses. See: https://mypy.readthedocs.io/en/stable/kinds_of_types.html#class-name-forward-references

view details

Craig Rodrigues

commit sha a54deeb1eb1acbffc7e337d3891baf40119eef66

Rework conditional import to work with mypy

view details

Craig Rodrigues

commit sha 44f91b73b7434d66006a00401825e30a59d27706

Turn off specific mypy errors on this line

view details

push time in 17 days

Pull request review commenttwisted/twisted

Fix mypy error: Too few arguments to "makeTestCaseClasses"

 def stop():             timedOutCall.cancel()  -    def makeTestCaseClasses(cls):+    @classmethod+    def makeTestCaseClasses(+        cls: Type['ReactorBuilder']+    ) -> Dict[str, Union[Type['ReactorBuilder'], Type['SynchronousTestCase']]]:         """         Create a L{SynchronousTestCase} subclass which mixes in C{cls} for each         known reactor and return a dict mapping their names to them.         """-        classes = {}+        classes = {}  # type: Dict[str, Union[Type['ReactorBuilder'], Type['SynchronousTestCase']]]   # noqa         for reactor in cls._reactors:             shortReactorName = reactor.split(".")[-1]-            name = (cls.__name__ + "." + shortReactorName + "Tests").replace(".", "_")-            class testcase(cls, SynchronousTestCase):+            name = (cls.__name__ + "." + shortReactorName ++                    "Tests").replace(".", "_")++            class testcase(cls, SynchronousTestCase):  # type: ignore

@mthuurne thanks for the feedback. I've changed this line to specifically turn off two mypy errors on this line:

class testcase(cls, SynchronousTestCase):  # type: ignore[valid-type,misc]
rodrigc

comment created time in 17 days

Pull request review commenttwisted/twisted

Fix mypy error: Too few arguments to "makeTestCaseClasses"

 def stop():             timedOutCall.cancel()  -    def makeTestCaseClasses(cls):+    @classmethod+    def makeTestCaseClasses(+        cls: Type['ReactorBuilder']+    ) -> Dict[str, Union[Type['ReactorBuilder'], Type['SynchronousTestCase']]]:         """         Create a L{SynchronousTestCase} subclass which mixes in C{cls} for each         known reactor and return a dict mapping their names to them.         """-        classes = {}+        classes = {}  # type: Dict[str, Union[Type['ReactorBuilder'], Type['SynchronousTestCase']]]   # noqa

@mthuurne Yes, for now I need to quote 'ReactorBuilder'. Since Twisted still supports Python 3.5 and 3.6, I cannot use from __future__ import annotations

rodrigc

comment created time in 17 days

Pull request review commenttwisted/twisted

Fix mypy error: Too few arguments to "makeTestCaseClasses"

  from twisted.python import log from twisted.python.failure import Failure-from twisted.python.compat import _PY3   # Access private APIs.-if platform.isWindows():-    process = None-else:+try:     from twisted.internet import process+except ImportError:+    process = None  # type: ignore

So based on this: https://github.com/python/mypy/issues/1297#issuecomment-508593494 I think we can remove the #type: ignore, and do this:

try
    from twisted.internet import process as _process
except ImportError:
    process = None  # type: ignore
else:
    process = _process
rodrigc

comment created time in 17 days

Pull request review commenttwisted/twisted

Fix mypy error: Too few arguments to "makeTestCaseClasses"

 def stop():             timedOutCall.cancel()  -    def makeTestCaseClasses(cls):+    @classmethod+    def makeTestCaseClasses(+        cls: Type['ReactorBuilder']+    ) -> Dict[str, Union[Type['ReactorBuilder'], Type['SynchronousTestCase']]]:         """         Create a L{SynchronousTestCase} subclass which mixes in C{cls} for each         known reactor and return a dict mapping their names to them.         """-        classes = {}+        classes = {}  # type: Dict[str, Union[Type['ReactorBuilder'], Type['SynchronousTestCase']]]   # noqa         for reactor in cls._reactors:             shortReactorName = reactor.split(".")[-1]-            name = (cls.__name__ + "." + shortReactorName + "Tests").replace(".", "_")-            class testcase(cls, SynchronousTestCase):+            name = (cls.__name__ + "." + shortReactorName ++                    "Tests").replace(".", "_")++            class testcase(cls, SynchronousTestCase):  # type: ignore

If I didn't put that #type: ignore there, mypy would give:

src/twisted/internet/test/reactormixins.py:343:28: error: Variable "cls" is not valid as a type  [valid-type]
                class testcase(cls, SynchronousTestCase):
                               ^
src/twisted/internet/test/reactormixins.py:343:28: note: See https://mypy.readthedocs.io/en/latest/common_issues.html#variables-vs-type-aliases
src/twisted/internet/test/reactormixins.py:343:28: error: Invalid base class "cls"  [misc]
                class testcase(cls, SynchronousTestCase):

The reason for this is that cls is a parameter, and the type of the parameter is only known at runtime. So mypy doesn't know what type it is, and can't check it.

rodrigc

comment created time in 17 days

Pull request review commenttwisted/twisted

Fix mypy error: Too few arguments to "makeTestCaseClasses"

 def stop():             timedOutCall.cancel()  -    def makeTestCaseClasses(cls):+    @classmethod+    def makeTestCaseClasses(+        cls: Type['ReactorBuilder']

I've changed this so SynchronousTestCase is not in quotes, but I still need 'ReactorBuilder` to be in quotes for the annotation.

rodrigc

comment created time in 17 days

Pull request review commenttwisted/twisted

Fix mypy error: Too few arguments to "makeTestCaseClasses"

 def stop():             timedOutCall.cancel()  -    def makeTestCaseClasses(cls):+    @classmethod+    def makeTestCaseClasses(+        cls: Type['ReactorBuilder']

Actually mypy did not complain. If I didn't put ReactorBuilder in quotes, pyflakes complained with:

src/twisted/internet/test/reactormixins.py:331:19 undefined name 'ReactorBuilder' src/twisted/internet/test/reactormixins.py:332:31 undefined name 'ReactorBuilder'

rodrigc

comment created time in 17 days

issue commentpython/mypy

Issues with conditional imports

@JukkaL While introducing mypy to the CI for the Twisted codebase, I ran into this problem which is similar to the examples mentioned in this issue, similar to the one brought up by @ethanhs:

https://github.com/twisted/twisted/pull/1261#discussion_r421875636

What is the way to deal with this:

try:
    from foo import A
except ImportError:
    A = None

Is there something that needs to be fixed in mypy? For now, I just put:

A = None # type:ignore

to turn off mypy errors on that line

JukkaL

comment created time in 17 days

Pull request review commenttwisted/twisted

Fix mypy error: Too few arguments to "makeTestCaseClasses"

 def stop():             timedOutCall.cancel()  -    def makeTestCaseClasses(cls):+    @classmethod+    def makeTestCaseClasses(+        cls: Type['ReactorBuilder']+    ) -> Dict[str, Union[Type['ReactorBuilder'], Type['SynchronousTestCase']]]:         """         Create a L{SynchronousTestCase} subclass which mixes in C{cls} for each         known reactor and return a dict mapping their names to them.         """-        classes = {}+        classes = {}  # type: Dict[str, Union[Type['ReactorBuilder'], Type['SynchronousTestCase']]]   # noqa         for reactor in cls._reactors:             shortReactorName = reactor.split(".")[-1]-            name = (cls.__name__ + "." + shortReactorName + "Tests").replace(".", "_")-            class testcase(cls, SynchronousTestCase):+            name = (cls.__name__ + "." + shortReactorName +

Yes, I made a lot of small changes like this to appease twistedchecker in terms of line spacing, line length, etc.

rodrigc

comment created time in 17 days

Pull request review commenttwisted/twisted

Fix mypy error: Too few arguments to "makeTestCaseClasses"

 def stop():             timedOutCall.cancel()  -    def makeTestCaseClasses(cls):+    @classmethod+    def makeTestCaseClasses(+        cls: Type['ReactorBuilder']+    ) -> Dict[str, Union[Type['ReactorBuilder'], Type['SynchronousTestCase']]]:         """         Create a L{SynchronousTestCase} subclass which mixes in C{cls} for each         known reactor and return a dict mapping their names to them.         """-        classes = {}+        classes = {}  # type: Dict[str, Union[Type['ReactorBuilder'], Type['SynchronousTestCase']]]   # noqa

I'm not sure exactly how mypy parses the file and comments to do all the type checks. I just kept the use the same to be consistent.

rodrigc

comment created time in 17 days

Pull request review commenttwisted/twisted

Fix mypy error: Too few arguments to "makeTestCaseClasses"

 def stop():             timedOutCall.cancel()  -    def makeTestCaseClasses(cls):+    @classmethod+    def makeTestCaseClasses(+        cls: Type['ReactorBuilder']

ReactorBuilder is defined in the same file, so I had to use the syntax Class name forward references, as described here: https://mypy.readthedocs.io/en/stable/kinds_of_types.html#class-name-forward-references

otherwise mypy would complain.

rodrigc

comment created time in 17 days

Pull request review commenttwisted/twisted

Fix mypy error: Too few arguments to "makeTestCaseClasses"

  from twisted.python import log from twisted.python.failure import Failure-from twisted.python.compat import _PY3   # Access private APIs.-if platform.isWindows():-    process = None-else:+try:     from twisted.internet import process+except ImportError:+    process = None  # type: ignore

There already is an open issue https://github.com/python/mypy/issues/1297#issuecomment-568663999 where this use-case was mentioned. I'll follow up there, and see what I can find out.

rodrigc

comment created time in 17 days

PullRequestEvent

PR closed twisted/twisted

Reviewers
Use unittest.skipIf decorator for skipping certain test functions.

https://twistedmatrix.com/trac/ticket/9812

This reduces errors reported by mypy of the form:

src/twisted/words/test/test_domish.py:193:9: error: "Callable[[ElementTests], Any]" has no attribute "skip"  [attr-defined]
            test_addContentBytes.skip = (
+1079 -1333

0 comment

67 changed files

rodrigc

pr closed time in 17 days

push eventtwisted/twisted

Craig Rodrigues

commit sha a9c60b23ae796b18a98562f9914c0b249706d442

Use unittest.skipIf decorator for skipping certain test functions. This reduces errors reported by mypy of the form: src/twisted/words/test/test_domish.py:193:9: error: "Callable[[ElementTests], Any]" has no attribute "skip" [attr-defined] test_addContentBytes.skip = (

view details

push time in 18 days

push eventtwisted/twisted

Craig Rodrigues

commit sha b73b52af21a76af3d5e67472119a8bc7c09c1e45

Use unittest.skipIf decorator for skipping certain test functions. This reduces errors reported by mypy of the form: src/twisted/words/test/test_domish.py:193:9: error: "Callable[[ElementTests], Any]" has no attribute "skip" [attr-defined] test_addContentBytes.skip = (

view details

push time in 18 days

push eventtwisted/twisted

Kyle Altendorf

commit sha f2eb582af5d12fe8deaa7920b55639b22c446c92

Require CPython 3.8 passes on macOS https://twistedmatrix.com/trac/ticket/9808

view details

Kyle Altendorf

commit sha f8f811684ad8f61fca362ecd33baba0801719fb6

Merge branch 'trunk' into 9808-altendky-require_3_8_passes_macos_ci

view details

Craig Rodrigues

commit sha 6d5ea4d4cc980ecf90cc05643fd9ff14e8b4d05d

Merge pull request #1258 from altendky/9808-altendky-require_3_8_passes_macos_ci Require CPython 3.8 passes on macOS Author: altendky Reviewer: rodrigc Fixes: ticket:9808

view details

Craig Rodrigues

commit sha 1e43d90f837ed40322f3b70c1f4b82093531f621

Use @classmethod decorator for makeTestCaseClasses() - Fix some pyflakes/pylint errors. - Add some type annotations to appease mypy

view details

Craig Rodrigues

commit sha a123fda3084605e04151101ea460010f9b513734

Add newsfragment

view details

push time in 18 days

push eventtwisted/twisted

Craig Rodrigues

commit sha a37faf870c9298277796fc92fa33fb04d1335041

Use unittest.skipIf decorator for skipping certain test functions. This reduces errors reported by mypy of the form: src/twisted/words/test/test_domish.py:193:9: error: "Callable[[ElementTests], Any]" has no attribute "skip" [attr-defined] test_addContentBytes.skip = (

view details

push time in 18 days

push eventtwisted/twisted

Kyle Altendorf

commit sha f2eb582af5d12fe8deaa7920b55639b22c446c92

Require CPython 3.8 passes on macOS https://twistedmatrix.com/trac/ticket/9808

view details

Kyle Altendorf

commit sha f8f811684ad8f61fca362ecd33baba0801719fb6

Merge branch 'trunk' into 9808-altendky-require_3_8_passes_macos_ci

view details

Craig Rodrigues

commit sha 6d5ea4d4cc980ecf90cc05643fd9ff14e8b4d05d

Merge pull request #1258 from altendky/9808-altendky-require_3_8_passes_macos_ci Require CPython 3.8 passes on macOS Author: altendky Reviewer: rodrigc Fixes: ticket:9808

view details

Craig Rodrigues

commit sha ebb77f824e36f0cf2656b5753bb436f7ffb88e86

Add newsfragment

view details

Craig Rodrigues

commit sha 25a93a67e4f85fdef67fcc3e924f04279039db08

Use unittest.skipIf decorator for skipping certain test functions. This reduces errors reported by mypy of the form: src/twisted/words/test/test_domish.py:193:9: error: "Callable[[ElementTests], Any]" has no attribute "skip" [attr-defined] test_addContentBytes.skip = (

view details

push time in 18 days

PR opened twisted/twisted

Reviewers
Use unittest.skipIf decorator for skipping certain test functions.

https://twistedmatrix.com/trac/ticket/9812

This reduces errors reported by mypy of the form:

src/twisted/words/test/test_domish.py:193:9: error: "Callable[[ElementTests], Any]" has no attribute "skip"  [attr-defined]
            test_addContentBytes.skip = (
+1051 -1350

0 comment

66 changed files

pr created time in 18 days

push eventtwisted/twisted

Craig Rodrigues

commit sha b330c0b600769ddd0344f4bb70d56eaa52c2af00

Add newsfragment

view details

Craig Rodrigues

commit sha 27ca9a16bd81d8b514233e6cd90c47c1f6f54970

Use unittest.skipIf decorator for skipping certain test functions. This reduces errors reported by mypy of the form: src/twisted/words/test/test_domish.py:193:9: error: "Callable[[ElementTests], Any]" has no attribute "skip" [attr-defined] test_addContentBytes.skip = (

view details

push time in 18 days

create barnchtwisted/twisted

branch : 9812-rodrigc-mypy

created branch time in 18 days

pull request commenttwisted/twisted

[WIP] Require CPython 3.8 passes on Windows

It's OK to fix tests as a side-effect of enabling CI. I've done it before. Getting the AsyncioSelectorReactor to work on Windows Python 3.8 looks like it will involve more work, so if you want to submit a separate PR to get that to work, that is OK.

altendky

comment created time in 19 days

create barnchtwisted/twisted

branch : 9809-altendky-require_3_8_passes_windows_ci

created branch time in 19 days

push eventaltendky/twisted

Craig Rodrigues

commit sha 217f6aba69c239712af6b524ddf265e9cebafed6

Skip tests if we cannot instantiate AsyncioSelectorReactor for any reason On Python 3.8 on Windows, instantiating AyncioSelectorReactor raises NotImplementedError.

view details

push time in 19 days

push eventaltendky/twisted

Kyle Altendorf

commit sha f2eb582af5d12fe8deaa7920b55639b22c446c92

Require CPython 3.8 passes on macOS https://twistedmatrix.com/trac/ticket/9808

view details

Kyle Altendorf

commit sha f8f811684ad8f61fca362ecd33baba0801719fb6

Merge branch 'trunk' into 9808-altendky-require_3_8_passes_macos_ci

view details

Craig Rodrigues

commit sha 6d5ea4d4cc980ecf90cc05643fd9ff14e8b4d05d

Merge pull request #1258 from altendky/9808-altendky-require_3_8_passes_macos_ci Require CPython 3.8 passes on macOS Author: altendky Reviewer: rodrigc Fixes: ticket:9808

view details

Craig Rodrigues

commit sha f8f8357e6a077d9daa7e56a163237cd6995a3018

Skip tests if we cannot import AsyncioSelectorReactor for any reason On Python 3.8 on Windows, importing AyncioSelectorReactor raises NotImplementedError.

view details

Craig Rodrigues

commit sha 0f5fc134cd584526c3762a88af2fd9fa2d9f6a7e

Merge branch 'trunk' into 9809-altendky-require_3_8_passes_windows_ci

view details

push time in 19 days

create barnchrodrigc/twisted

branch : 9809-altendky-require_3_8_passes_windows_ci

created branch time in 19 days

pull request commenttwisted/twisted

Require CPython 3.8 passes on Windows

@altendky This fails on Windows due to this: https://dev.azure.com/twistedmatrix/twisted/_build/results?buildId=1711&view=logs&j=c822da56-1c3f-5527-8882-a570698b0a88&t=e0a40107-1633-5cd6-a3ae-f8d8a91ebac8&l=16013

This tries to instantiate the AsyncioSelectorReactor. It looks like the AynsCIO which looks like it doesn't work on Windows

In this test: https://github.com/twisted/twisted/blob/21692573637727252fdc21c872968d413e02cd13/src/twisted/internet/test/test_asyncioreactor.py#L15

It looks like on Python 3.8, NotImplementedError is raised instead of ImportError.

So probably this test needs to be changed so that it can handle NotImplementedError in addition to ImportError

altendky

comment created time in 19 days

more