From 210b733422b1362e63054882da33e491d2aa41d1 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Sun, 3 May 2020 16:08:44 +0300 Subject: [PATCH] Drop remains of Python 2 support code --- check_manifest.py | 25 +++++++------------------ tests.py | 7 +------ 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/check_manifest.py b/check_manifest.py index 15ff952..4afc50e 100755 --- a/check_manifest.py +++ b/check_manifest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Check the MANIFEST.in file in a Python source package for completeness. This script works by building a source distribution archive (by running @@ -13,10 +13,10 @@ with stale egg-info/SOURCES.txt files that may cause files not mentioned in MANIFEST.in to be included nevertheless. """ -from __future__ import print_function import argparse import codecs +import configparser import fnmatch import locale import os @@ -33,18 +33,7 @@ from contextlib import contextmanager, closing from distutils.filelist import translate_pattern from distutils.text_file import TextFile - -try: - from xml.etree import cElementTree as ET -except ImportError: - # Python 3.9+ - from xml.etree import ElementTree as ET - -try: - import ConfigParser -except ImportError: - # Python 3.x - import configparser as ConfigParser +from xml.etree import ElementTree as ET import toml @@ -63,7 +52,7 @@ class Failure(Exception): # User interface # -class UI(object): +class UI: def __init__(self, verbosity=1): self.verbosity = verbosity @@ -382,7 +371,7 @@ def add_prefix_to_each(prefix, filelist): return [posixpath.join(prefix, name) for name in filelist] -class VCS(object): +class VCS: def __init__(self, ui): self.ui = ui @@ -582,7 +571,7 @@ def normalize_name(name): # Packaging logic # -class IgnoreList(object): +class IgnoreList: def __init__(self): self._regexps = [] @@ -731,7 +720,7 @@ def _load_config(): return config["tool"][CFG_SECTION_CHECK_MANIFEST] search_files = ['setup.cfg', 'tox.ini'] - config_parser = ConfigParser.ConfigParser() + config_parser = configparser.ConfigParser() for filename in search_files: if (config_parser.read([filename]) and config_parser.has_section(CFG_SECTION_CHECK_MANIFEST)): diff --git a/tests.py b/tests.py index dde0a11..575f5cc 100644 --- a/tests.py +++ b/tests.py @@ -15,14 +15,9 @@ import zipfile from contextlib import closing from functools import partial -from io import BytesIO +from io import BytesIO, StringIO from xml.etree import ElementTree as ET -try: - from cStringIO import StringIO # Python 2.x -except ImportError: - from io import StringIO # Python 3.x - import mock from check_manifest import rmtree