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

Remove Python2 support #24

Open
wants to merge 1 commit into
base: main
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
3 changes: 1 addition & 2 deletions bin/make_localpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
pip install --find-links=/tmp/downloads --no-index argparse Jinja2
"""

from __future__ import with_statement, print_function
from fnmatch import fnmatch
import os.path
import shutil
Expand All @@ -51,7 +50,7 @@
__copyright__ = "(c) 2013 by Jens Engel"


class Package(object):
class Package:
"""
Package entity that keeps track of:
* one or more versions of this package
Expand Down
3 changes: 1 addition & 2 deletions bin/toxcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

* copytree
* copy
* py2to3

REQUIRES:
* argparse
Expand Down Expand Up @@ -181,7 +180,7 @@ def discover_commands():
return commands


class Command(object):
class Command:
def __init__(self, name, func):
assert isinstance(name, basestring)
assert callable(func)
Expand Down
1 change: 0 additions & 1 deletion parse_type/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
parse-types from other, existing types.
"""

from __future__ import absolute_import
from parse_type.cardinality import Cardinality
from parse_type.builder import TypeBuilder, build_type_dict

Expand Down
1 change: 0 additions & 1 deletion parse_type/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@

"""

from __future__ import absolute_import
import inspect
import re
import enum
Expand Down
4 changes: 1 addition & 3 deletions parse_type/cardinality.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
for a data type with the specified cardinality.
"""

# -- USE: enum34
from __future__ import absolute_import
from enum import Enum


Expand Down Expand Up @@ -84,7 +82,7 @@ def compute_group_count(self, pattern):
# -----------------------------------------------------------------------------
# CLASS: TypeBuilder
# -----------------------------------------------------------------------------
class TypeBuilder(object):
class TypeBuilder:
"""Provides a utility class to build type-converters (parse_types) for parse.
It supports to build new type-converters for different cardinality
based on the type-converter for cardinality one.
Expand Down
8 changes: 3 additions & 5 deletions parse_type/cardinality_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
"{persons:Person+}" #< Cardinality: 1..* = one or more = many
"""

from __future__ import absolute_import
import six
from parse_type.cardinality import Cardinality, TypeBuilder


Expand All @@ -19,7 +17,7 @@ class MissingTypeError(KeyError): # pylint: disable=missing-docstring
# -----------------------------------------------------------------------------
# CLASS: Cardinality (Field Part)
# -----------------------------------------------------------------------------
class CardinalityField(object):
class CardinalityField:
"""Cardinality field for parse format expression, ala:

"{person:Person?}" #< Cardinality: 0..1 = zero or one = optional
Expand Down Expand Up @@ -81,7 +79,7 @@ def make_type(cls, basename, cardinality):
# -----------------------------------------------------------------------------
# CLASS: CardinalityFieldTypeBuilder
# -----------------------------------------------------------------------------
class CardinalityFieldTypeBuilder(object):
class CardinalityFieldTypeBuilder:
"""Utility class to create type converters based on:

* the CardinalityField naming scheme and
Expand Down Expand Up @@ -115,7 +113,7 @@ def parse_number(text):
:raises: ValueError, if type_name does not end with CardinalityField
:raises: MissingTypeError, if type_converter is missing in type_dict
"""
assert isinstance(type_name, six.string_types)
assert isinstance(type_name, str)
if not CardinalityField.matches_type(type_name):
message = "type_name='%s' has no CardinalityField" % type_name
raise ValueError(message)
Expand Down
1 change: 0 additions & 1 deletion parse_type/cfparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
cardinality fields in (user-defined) types.
"""

from __future__ import absolute_import
import logging
import parse
from .cardinality_field import CardinalityField, CardinalityFieldTypeBuilder
Expand Down
9 changes: 4 additions & 5 deletions parse_type/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# pylint: disable=all
#
# -- ORIGINAL-CODE STARTS-HERE ------------------------------------------------
from __future__ import absolute_import

import logging
import re
Expand Down Expand Up @@ -414,7 +413,7 @@ def extract_format(format, extra_types):
PARSE_RE = re.compile(r"({{|}}|{[\w-]*(?:\.[\w-]+|\[[^]]+])*(?::[^}]+)?})")


class Parser(object):
class Parser:
"""Encapsulate a format string that may be used to parse other strings."""

def __init__(self, format, extra_types=None, case_sensitive=False):
Expand Down Expand Up @@ -868,7 +867,7 @@ def _handle_field(self, field):
return s


class Result(object):
class Result:
"""The result of a parse() or search().

Fixed results may be looked up using `result[index]`.
Expand Down Expand Up @@ -896,7 +895,7 @@ def __contains__(self, name):
return name in self.named


class Match(object):
class Match:
"""The result of a parse() or search() if no results are generated.

This class is only used to expose internal used regex match objects
Expand All @@ -912,7 +911,7 @@ def evaluate_result(self):
return self.parser.evaluate_result(self.match)


class ResultIterator(object):
class ResultIterator:
"""The result of a findall() operation.

Each element is a Result instance.
Expand Down
8 changes: 3 additions & 5 deletions parse_type/parse_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
Provides generic utility classes for the :class:`parse.Parser` class.
"""

from __future__ import absolute_import
from collections import namedtuple
import parse
import six


# -- HELPER-CLASS: For format part in a Field.
Expand All @@ -21,7 +19,7 @@ def make_format_spec(type=None, width="", zero=False, align=None, fill=None,
return FormatSpec(type, width, zero, align, fill, precision)
# pylint: enable=redefined-builtin

class Field(object):
class Field:
"""
Provides a ValueObject for a Field in a parse expression.

Expand Down Expand Up @@ -66,7 +64,7 @@ def __eq__(self, other):
format1 = self.format or ""
format2 = other.format or ""
return (self.name == other.name) and (format1 == format2)
elif isinstance(other, six.string_types):
elif isinstance(other, str):
return str(self) == other
else:
raise ValueError(other)
Expand Down Expand Up @@ -150,7 +148,7 @@ def extract_format_spec(cls, format):
return FormatSpec(type, width, zero, align, fill, precision)


class FieldParser(object):
class FieldParser:
"""
Utility class that parses/extracts fields in parse expressions.
"""
Expand Down
5 changes: 1 addition & 4 deletions py.requirements/basic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@
# * http://www.pip-installer.org/
# ============================================================================

parse >= 1.18.0; python_version >= '3.0'
parse >= 1.13.1; python_version <= '2.7'
enum34; python_version < '3.4'
six >= 1.15
parse >= 1.18.0
8 changes: 2 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ authors = [
]
description = "Simplifies to build parse types based on the parse module"
readme = "README.rst"
requires-python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
requires-python = ">=3.2"
keywords = ["parse", "parsing"]
license = {text = "MIT"}
classifiers = [
Expand All @@ -26,7 +26,6 @@ classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
Expand All @@ -43,10 +42,7 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"parse >= 1.18.0; python_version >= '3.0'",
"parse >= 1.13.1; python_version <= '2.7'",
"enum34; python_version < '3.4'",
"six >= 1.15",
"parse >= 1.18.0",
]
# PREPARED:
dynamic = ["version"]
Expand Down
10 changes: 3 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,9 @@ def find_packages_by_root_package(where):
include_package_data = True,

# -- REQUIREMENTS:
python_requires=">=2.7, !=3.0.*, !=3.1.*",
python_requires=">=3.2",
install_requires=[
"parse >= 1.18.0; python_version >= '3.0'",
"parse >= 1.13.1; python_version <= '2.7'",
"enum34; python_version < '3.4'",
"six >= 1.15",
"parse >= 1.18.0",
],
tests_require=[
"pytest < 5.0; python_version < '3.0'", # >= 4.2
Expand All @@ -88,8 +85,7 @@ def find_packages_by_root_package(where):
"build >= 0.5.1",
"twine >= 1.13.0",
"coverage >= 4.4",
"pytest < 5.0; python_version < '3.0'", # >= 4.2
"pytest >= 5.0; python_version >= '3.0'",
"pytest >= 5.0",
"pytest-html >= 1.19.0",
"pytest-cov",
"tox >=2.8,<4.0",
Expand Down
2 changes: 0 additions & 2 deletions tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
* https://github.com/pyinvoke/invoke
"""

from __future__ import absolute_import, print_function

# -----------------------------------------------------------------------------
# IMPORTS:
# -----------------------------------------------------------------------------
Expand Down
2 changes: 0 additions & 2 deletions tasks/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
* https://github.com/pyinvoke/invoke
"""

from __future__ import absolute_import, print_function

# -----------------------------------------------------------------------------
# AUTO-MAIN:
# -----------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion tasks/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Provides tasks to build documentation with sphinx, etc.
"""

from __future__ import absolute_import, print_function
import os
import sys
from invoke import task, Collection
Expand Down
3 changes: 1 addition & 2 deletions tasks/invoke_dry_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def destroy_something(ctx, path, dry_run=False):
ctx.run("rm -rf {}".format(path))
"""

from __future__ import print_function
from contextlib import contextmanager

@contextmanager
Expand All @@ -36,7 +35,7 @@ def dry_run_mode(ctx):
ctx.config.run.dry = initial_dry_run


class DryRunContext(object):
class DryRunContext:
PREFIX = "DRY-RUN: "
SCHEMA = "{prefix}{command}"
SCHEMA_WITH_KWARGS = "{prefix}{command} (with kwargs={kwargs})"
Expand Down
1 change: 0 additions & 1 deletion tasks/py.requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
invoke >=1.7.0,<2.0; python_version < '3.6'
invoke >=1.7.0; python_version >= '3.6'
pycmd
six >= 1.15.0

# -- HINT, was RENAMED: path.py => path (for python3)
path >= 13.1.0; python_version >= '3.5'
Expand Down
1 change: 0 additions & 1 deletion tasks/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
* https://packaging.python.org/tutorials/distributing-packages/
"""

from __future__ import absolute_import, print_function
from invoke import Collection, task
from invoke_cleanup import path_glob
from .invoke_dry_run import DryRunContext
Expand Down
1 change: 0 additions & 1 deletion tasks/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Invoke test tasks.
"""

from __future__ import print_function
import os.path
import sys
from invoke import task, Collection
Expand Down
1 change: 0 additions & 1 deletion tests/parse_tests_with_parse_type/test_bugs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -- REPLACE: parse with parse_type.parse
from __future__ import absolute_import, print_function
from parse_type import parse


Expand Down
1 change: 0 additions & 1 deletion tests/parse_tests_with_parse_type/test_findall.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -- REPLACE: parse with parse_type.parse
from __future__ import absolute_import, print_function
from parse_type import parse

# -- ORIGINAL_SOURCE_STARTS_HERE:
Expand Down
1 change: 0 additions & 1 deletion tests/parse_tests_with_parse_type/test_parse.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# coding: utf-8
# -- REPLACE: parse with parse_type.parse
from __future__ import absolute_import, print_function
from parse_type import parse

# -- ORIGINAL_SOURCE_STARTS_HERE:
Expand Down
1 change: 0 additions & 1 deletion tests/parse_tests_with_parse_type/test_parsetype.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -- REPLACE: parse with parse_type.parse
from __future__ import absolute_import, print_function
from parse_type import parse

# -- ORIGINAL_SOURCE_STARTS_HERE:
Expand Down
1 change: 0 additions & 1 deletion tests/parse_tests_with_parse_type/test_pattern.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -- REPLACE: parse with parse_type.parse
from __future__ import absolute_import, print_function
from parse_type import parse

# -- ORIGINAL_SOURCE_STARTS_HERE:
Expand Down
1 change: 0 additions & 1 deletion tests/parse_tests_with_parse_type/test_result.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -- REPLACE: parse with parse_type.parse
from __future__ import absolute_import, print_function
from parse_type import parse

# -- ORIGINAL_SOURCE_STARTS_HERE:
Expand Down
1 change: 0 additions & 1 deletion tests/parse_tests_with_parse_type/test_search.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -- REPLACE: parse with parse_type.parse
from __future__ import absolute_import, print_function
from parse_type import parse

# -- ORIGINAL_SOURCE_STARTS_HERE:
Expand Down
6 changes: 1 addition & 5 deletions tests/parse_type_test.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import
from parse_type import TypeBuilder
from enum import Enum
try:
import unittest2 as unittest
except ImportError:
import unittest
import unittest


# -----------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion tests/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
REQUIRES: parse >= 1.8.4 ('pattern' attribute support)
"""

from __future__ import absolute_import
import re
import unittest
import parse
Expand Down
1 change: 0 additions & 1 deletion tests/test_cardinality.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
Test suite to test the :mod:`parse_type.cardinality` module.
"""

from __future__ import absolute_import
from .parse_type_test import ParseTypeTestCase, parse_number
from parse_type import Cardinality, TypeBuilder, build_type_dict
from parse import Parser
Expand Down
Loading