Run ruff to fix test errors (#10398)

This is mostly removing unused imports, plus one unused `import as`. Had
to put back imports being used with `eval` -- see the second commit.
This commit is contained in:
ohemorange 2025-08-07 15:10:02 -07:00 committed by GitHub
parent 13954a783a
commit 5859e50e44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
44 changed files with 2 additions and 62 deletions

View file

@ -9,7 +9,6 @@ from josepy.jwk import JWKEC
import pytest
import requests
from acme import errors
from acme._internal.tests import test_util
CERT = test_util.load_cert('cert.pem')

View file

@ -1,11 +1,7 @@
"""Tests for acme.crypto_util."""
import ipaddress
import itertools
import socket
import socketserver
import sys
import threading
import time
from typing import List
import unittest
from unittest import mock
@ -16,7 +12,6 @@ from cryptography import x509
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import rsa, x25519
from acme import errors
from acme._internal.tests import test_util

View file

@ -2,7 +2,6 @@
import datetime
import sys
import unittest
import warnings
import josepy as jose
import pytest

View file

@ -20,7 +20,7 @@ def _test_it(submodule, attribute):
# We use the imports below with eval, but pylint doesn't
# understand that.
import josepy # pylint: disable=unused-import
import josepy # pylint: disable=unused-import
import acme # pylint: disable=unused-import
acme_jose_mod = eval(acme_jose_path) # pylint: disable=eval-used

View file

@ -11,12 +11,8 @@ from unittest import mock
import josepy as jose
import pytest
import requests
from cryptography import x509
from cryptography.hazmat.primitives import serialization
from acme import challenges
from acme import crypto_util
from acme import errors
from acme._internal.tests import test_util

View file

@ -2,7 +2,6 @@
"""Test for certbot_apache._internal.configurator AutoHSTS functionality"""
import re
import sys
import unittest
from unittest import mock
import pytest

View file

@ -1,6 +1,5 @@
"""Test for certbot_apache._internal.configurator for Centos overrides"""
import sys
import unittest
from unittest import mock
import pytest

View file

@ -1,7 +1,6 @@
"""Tests for certbot_apache._internal.parser."""
import shutil
import sys
import unittest
import pytest

View file

@ -1,7 +1,6 @@
"""Test for certbot_apache._internal.configurator implementations of reverter"""
import shutil
import sys
import unittest
from unittest import mock
import pytest

View file

@ -1,7 +1,6 @@
"""Test for certbot_apache._internal.configurator for Debian overrides"""
import shutil
import sys
import unittest
from unittest import mock
import pytest

View file

@ -1,6 +1,5 @@
"""Test for certbot_apache._internal.configurator for Fedora 29+ overrides"""
import sys
import unittest
from unittest import mock
import pytest

View file

@ -1,6 +1,5 @@
"""Test for certbot_apache._internal.configurator for Gentoo overrides"""
import sys
import unittest
from unittest import mock
import pytest

View file

@ -2,7 +2,6 @@
import errno
import sys
from typing import List
import unittest
from unittest import mock
import pytest

View file

@ -1,7 +1,6 @@
"""Tests for certbot_apache._internal.parser."""
import shutil
import sys
import unittest
from unittest import mock
import pytest

View file

@ -1,5 +1,4 @@
import os
import sys
from setuptools import find_packages
from setuptools import setup

View file

@ -1,5 +1,4 @@
import os
import sys
from setuptools import find_packages
from setuptools import setup

View file

@ -1,5 +1,4 @@
import os
import sys
from setuptools import find_packages
from setuptools import setup

View file

@ -1,5 +1,4 @@
import os
import sys
from setuptools import find_packages
from setuptools import setup

View file

@ -1,5 +1,4 @@
import os
import sys
from setuptools import find_packages
from setuptools import setup

View file

@ -1,5 +1,4 @@
import os
import sys
from setuptools import find_packages
from setuptools import setup

View file

@ -1,5 +1,4 @@
import os
import sys
from setuptools import find_packages
from setuptools import setup

View file

@ -1,12 +1,10 @@
"""Tests for certbot_dns_linode._internal.dns_linode."""
import sys
import unittest
from unittest import mock
import pytest
from certbot import errors
from certbot.compat import os
from certbot.plugins import dns_test_common
from certbot.plugins import dns_test_common_lexicon

View file

@ -1,5 +1,4 @@
import os
import sys
from setuptools import find_packages
from setuptools import setup

View file

@ -1,5 +1,4 @@
import os
import sys
from setuptools import find_packages
from setuptools import setup

View file

@ -1,5 +1,4 @@
import os
import sys
from setuptools import find_packages
from setuptools import setup

View file

@ -1,5 +1,4 @@
import os
import sys
from setuptools import find_packages
from setuptools import setup

View file

@ -1,5 +1,4 @@
import os
import sys
from setuptools import find_packages
from setuptools import setup

View file

@ -1,5 +1,4 @@
import os
import sys
from setuptools import find_packages
from setuptools import setup

View file

@ -1,6 +1,5 @@
"""Test certbot_nginx._internal.display_ops."""
import sys
import unittest
import pytest

View file

@ -1,6 +1,5 @@
"""Tests for certbot_nginx._internal.http_01"""
import sys
import unittest
from unittest import mock
import josepy as jose

View file

@ -3,7 +3,6 @@ import copy
import importlib.resources
import shutil
import tempfile
import sys
from contextlib import contextmanager
from unittest import mock

View file

@ -1,7 +1,6 @@
"""Tests for certbot._internal.cli."""
import argparse
import copy
from importlib import reload as reload_module
import io
import sys
import tempfile

View file

@ -2,7 +2,6 @@
import functools
import multiprocessing
import sys
import unittest
from unittest import mock
import pytest

View file

@ -1,7 +1,6 @@
"""Tests for certbot._internal.plugins.manual"""
import sys
import textwrap
import unittest
from unittest import mock
import pytest

View file

@ -220,7 +220,6 @@ class TestChooseConfiguratorPlugins(unittest.TestCase):
return mock_ep
def _parseArgs(self, args):
from certbot import configuration
from certbot._internal import cli
return cli.prepare_and_parse_args(self.plugins, args.split())

View file

@ -2,9 +2,7 @@
import errno
import socket
import sys
from typing import Dict
from typing import Set
from typing import Tuple
import unittest
from unittest import mock

View file

@ -18,7 +18,6 @@ import certbot.tests.util as test_util
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives import serialization, hashes
from cryptography import x509
from cryptography.x509 import Certificate
def make_cert_with_lifetime(not_before: datetime.datetime, lifetime_days: int) -> bytes:
"""Return PEM of a self-signed certificate with the given notBefore and lifetime."""
@ -451,7 +450,6 @@ class RenewalTest(test_util.ConfigTestCase):
@mock.patch('certbot._internal.storage.RenewableCert.ocsp_revoked')
def test_resilient_ari_check(self, mock_ocsp):
from certbot._internal import renewal
from acme import messages
rc_path = test_util.make_lineage(self.config.config_dir, 'sample-renewal.conf')
renewable_cert = storage.RenewableCert(rc_path, self.config)

View file

@ -1,6 +1,5 @@
"""Tests for renewal updater interfaces"""
import sys
import unittest
from unittest import mock
import pytest

View file

@ -4,7 +4,6 @@ import logging
import shutil
import sys
import tempfile
import unittest
from unittest import mock
import pytest

View file

@ -12,14 +12,12 @@ import configobj
import pytest
import certbot
from certbot import configuration
from certbot import errors
from certbot._internal.storage import ALL_FOUR
from certbot.compat import filesystem
from certbot.compat import os
import certbot.tests.util as test_util
from typing import Optional, Any
def unlink_all(rc_object):
"""Unlink all four items associated with this RenewableCert."""

View file

@ -36,11 +36,8 @@ import sys
import tempfile
import time
import traceback
import urllib.error as urllib_error
import urllib.request as urllib_request
import boto3
from botocore.exceptions import ClientError
from fabric import Config
from fabric import Connection
import yaml
@ -185,7 +182,7 @@ def block_until_ssh_open(ipstring, wait_time=10, timeout=120):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((ipstring, 22))
reached = True
except OSError as err:
except OSError:
time.sleep(wait_time)
t_elapsed += wait_time
sock.close()

View file

@ -7,7 +7,6 @@ See https://github.com/PyCQA/pylint/blob/b20a2984c94e2946669d727dbda78735882bf50
See https://docs.pytest.org/en/latest/writing_plugins.html
"""
import os.path
import re
from pylint.checkers import BaseChecker

View file

@ -23,17 +23,13 @@ should execute successfully.
"""
import argparse
import getpass
import glob
import os.path
import re
import subprocess
import sys
import tempfile
from zipfile import ZipFile
from azure.devops.connection import Connection
import requests
# Path to the root directory of the Certbot repository containing this script
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

View file

@ -10,12 +10,10 @@ from multiprocessing.managers import SyncManager
import os
from os.path import basename
from os.path import dirname
from os.path import exists
from os.path import join
from os.path import realpath
import random
import re
import shutil
import string
import subprocess
import sys