Skip to content

Commit

Permalink
chore: drop 2.7 and 3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Dec 23, 2021
1 parent 57631a1 commit 3ec6bac
Show file tree
Hide file tree
Showing 33 changed files with 116 additions and 359 deletions.
6 changes: 2 additions & 4 deletions conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ requirements:

run:
- python
- paramiko<2.4 # [py26]
- paramiko # [not py26]
- paramiko

build:
number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0) }}
Expand All @@ -35,8 +34,7 @@ test:
requires:
# Put any additional test requirements here. For example
- pytest
- paramiko<2.4 # [py26]
- paramiko # [not py26]
- paramiko

about:
home: https://plumbum.readthedocs.io
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import nox

ALL_PYTHONS = ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9"]
ALL_PYTHONS = ["3.6", "3.7", "3.8", "3.9", "3.10"]

nox.options.sessions = ["lint", "tests"]

Expand Down
6 changes: 1 addition & 5 deletions plumbum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,7 @@
# ===================================================================================================
import sys
from types import ModuleType

try:
from typing import List
except ImportError:
pass
from typing import List


class LocalModule(ModuleType):
Expand Down
11 changes: 6 additions & 5 deletions plumbum/cli/application.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import functools
import inspect
import os
import sys
from collections import defaultdict
from textwrap import TextWrapper

from plumbum import colors, local
from plumbum.cli.i18n import get_translation_for
from plumbum.lib import getdoc, six
from plumbum.lib import getdoc

from .switches import (
CountOf,
Expand Down Expand Up @@ -503,8 +504,8 @@ def _validate_args(self, swfuncs, tailargs):
)
)

m = six.getfullargspec(self.main)
max_args = six.MAXSIZE if m.varargs else len(m.args) - 1
m = inspect.getfullargspec(self.main)
max_args = sys.maxsize if m.varargs else len(m.args) - 1
min_args = len(m.args) - 1 - (len(m.defaults) if m.defaults else 0)
if len(tailargs) < min_args:
raise PositionalArgumentsError(
Expand All @@ -523,7 +524,7 @@ def _validate_args(self, swfuncs, tailargs):
).format(max_args, tailargs)
)

# Positional arguement validataion
# Positional argument validation
if hasattr(self.main, "positional"):
tailargs = self._positional_validate(
tailargs,
Expand Down Expand Up @@ -850,7 +851,7 @@ def wrapped_paragraphs(text, width):
for line in wrapped_paragraphs(self.DESCRIPTION_MORE, cols):
print(line)

m = six.getfullargspec(self.main)
m = inspect.getfullargspec(self.main)
tailargs = m.args[1:] # skip self
if m.defaults:
for i, d in enumerate(reversed(m.defaults)):
Expand Down
10 changes: 4 additions & 6 deletions plumbum/cli/config.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import sys
from abc import abstractmethod
from abc import ABC, abstractmethod
from configparser import ConfigParser, NoOptionError, NoSectionError

from plumbum import local
from plumbum.lib import _setdoc, six

from configparser import ConfigParser, NoOptionError, NoSectionError
from plumbum.lib import _setdoc


class ConfigBase(six.ABC):
class ConfigBase(ABC):
"""Base class for Config parsers.
:param filename: The file to use
Expand Down
5 changes: 1 addition & 4 deletions plumbum/cli/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ def get_translation_for(package_name):
except ImportError:
pkg_resources = None

try:
from typing import Callable, List, Tuple
except ImportError:
pass
from typing import Callable, List, Tuple

local_dir = os.path.basename(__file__)

Expand Down
5 changes: 2 additions & 3 deletions plumbum/cli/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
import datetime
import sys
import warnings
from abc import abstractmethod
from abc import ABC, abstractmethod

from plumbum.cli.termsize import get_terminal_size
from plumbum.lib import six


class ProgressBase(six.ABC):
class ProgressBase(ABC):
"""Base class for progress bars. Customize for types of progress bars.
:param iterator: The iterator to wrap with a progress bar
Expand Down
23 changes: 9 additions & 14 deletions plumbum/cli/switches.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from abc import abstractmethod
import inspect
from abc import ABC, abstractmethod

from plumbum import local
from plumbum.cli.i18n import get_translation_for
from plumbum.lib import getdoc, six
from plumbum.lib import getdoc

_translation = get_translation_for(__name__)
_, ngettext = _translation.gettext, _translation.ngettext
Expand Down Expand Up @@ -172,7 +173,7 @@ def set_terse(self):

def deco(func):
if argname is None:
argspec = six.getfullargspec(func).args
argspec = inspect.getfullargspec(func).args
if len(argspec) == 2:
argname2 = argspec[1]
else:
Expand Down Expand Up @@ -364,7 +365,7 @@ def __init__(self, *args, **kargs):
self.kargs = kargs

def __call__(self, function):
m = six.getfullargspec(function)
m = inspect.getfullargspec(function)
args_names = list(m.args[1:])

positional = [None] * len(args_names)
Expand All @@ -388,7 +389,7 @@ def __call__(self, function):
return function


class Validator(six.ABC):
class Validator(ABC):
__slots__ = ()

@abstractmethod
Expand Down Expand Up @@ -497,14 +498,10 @@ def __call__(self, value, check_csv=True):
return opt(value)
except ValueError:
pass
raise ValueError(
f"Invalid value: {value} (Expected one of {self.values})"
)
raise ValueError(f"Invalid value: {value} (Expected one of {self.values})")

def choices(self, partial=""):
choices = {
opt if isinstance(opt, str) else f"({opt})" for opt in self.values
}
choices = {opt if isinstance(opt, str) else f"({opt})" for opt in self.values}
if partial:
choices = {opt for opt in choices if opt.lower().startswith(partial)}
return choices
Expand Down Expand Up @@ -542,9 +539,7 @@ def ExistingDirectory(val):
def MakeDirectory(val):
p = local.path(val)
if p.is_file():
raise ValueError(
f"{val} is a file, should be nonexistent, or a directory"
)
raise ValueError(f"{val} is a file, should be nonexistent, or a directory")
elif not p.exists():
p.mkdir()
return p
Expand Down
4 changes: 1 addition & 3 deletions plumbum/colorlib/_ipython_ext.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import sys
from io import StringIO

import IPython.display
from IPython.core.magic import Magics, cell_magic, magics_class, needs_local_scope

from io import StringIO


valid_choices = [x[8:] for x in dir(IPython.display) if "display_" == x[:8]]


Expand Down
10 changes: 2 additions & 8 deletions plumbum/colorlib/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,15 +306,9 @@

_base_pattern = [(n // 4, n // 2 % 2, n % 2) for n in range(8)]
_base_html = (
[
f"#{x[2] * 192:02x}{x[1] * 192:02x}{x[0] * 192:02x}"
for x in _base_pattern
]
[f"#{x[2] * 192:02x}{x[1] * 192:02x}{x[0] * 192:02x}" for x in _base_pattern]
+ ["#808080"]
+ [
f"#{x[2] * 255:02x}{x[1] * 255:02x}{x[0] * 255:02x}"
for x in _base_pattern
][1:]
+ [f"#{x[2] * 255:02x}{x[1] * 255:02x}{x[0] * 255:02x}" for x in _base_pattern][1:]
)
color_html = _base_html + _normal_html + _grey_html

Expand Down
10 changes: 2 additions & 8 deletions plumbum/colorlib/styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
import platform
import re
import sys
from abc import ABCMeta, abstractmethod
from abc import ABC, ABCMeta, abstractmethod
from copy import copy
from typing import IO, Dict, Union

from .names import (
FindNearest,
Expand All @@ -24,13 +25,6 @@
from_html,
)

from abc import ABC

try:
from typing import IO, Dict, Union
except ImportError:
pass

__all__ = [
"Color",
"Style",
Expand Down
15 changes: 7 additions & 8 deletions plumbum/commands/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import plumbum.commands.modifiers
from plumbum.commands.processes import iter_lines, run_proc
from plumbum.lib import six


class RedirectionError(Exception):
Expand All @@ -27,7 +26,7 @@ class RedirectionError(Exception):

def shquote(text):
"""Quotes the given text with shell escaping (assumes as syntax similar to ``sh``)"""
text = six.str(text)
text = str(text)
return shlex.quote(text)


Expand Down Expand Up @@ -341,7 +340,7 @@ def popen(self, args=(), cwd=None, env=None, **kwargs):
args,
cwd=self.cwd if cwd is None else cwd,
env=dict(self.env, **env),
**kwargs
**kwargs,
)


Expand Down Expand Up @@ -530,7 +529,7 @@ def popen(self, args=(), **kwargs):
if "stdin" in kwargs and kwargs["stdin"] != PIPE:
raise RedirectionError("stdin is already redirected")
data = self.data
if isinstance(data, six.unicode_type) and self._get_encoding() is not None:
if isinstance(data, str) and self._get_encoding() is not None:
data = data.encode(self._get_encoding())
f = TemporaryFile()
while data:
Expand Down Expand Up @@ -564,7 +563,7 @@ def _get_encoding(self):
return self.custom_encoding

def formulate(self, level=0, args=()):
argv = [six.str(self.executable)]
argv = [str(self.executable)]
for a in args:
if a is None:
continue
Expand All @@ -575,10 +574,10 @@ def formulate(self, level=0, args=()):
argv.extend(a.formulate(level + 1))
elif isinstance(a, (list, tuple)):
argv.extend(
shquote(b) if level >= self.QUOTE_LEVEL else six.str(b) for b in a
shquote(b) if level >= self.QUOTE_LEVEL else str(b) for b in a
)
else:
argv.append(shquote(a) if level >= self.QUOTE_LEVEL else six.str(a))
argv.append(shquote(a) if level >= self.QUOTE_LEVEL else str(a))
# if self.custom_encoding:
# argv = [a.encode(self.custom_encoding) for a in argv if isinstance(a, six.string_types)]
# argv = [a.encode(self.custom_encoding) for a in argv if isinstance(a, str)]
return argv
Loading

0 comments on commit 3ec6bac

Please sign in to comment.