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

Drop Python2 #23

Merged
merged 8 commits into from
Sep 6, 2022
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/pypi_upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
build:
name: pythonfinder PyPI Upload
name: Plette PyPI Upload
runs-on: ubuntu-latest
env:
CI: "1"
Expand Down Expand Up @@ -37,7 +37,7 @@ jobs:

- name: Install latest tools for build
run: |
python -m pip install build invoke -e .[dev]
python -m pip install build .
- name: Build wheels
run: |
python -m build
Expand Down
49 changes: 0 additions & 49 deletions .travis.yml

This file was deleted.

411 changes: 319 additions & 92 deletions Pipfile.lock

Large diffs are not rendered by default.

26 changes: 0 additions & 26 deletions appveyor.yml

This file was deleted.

13 changes: 5 additions & 8 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,18 @@ classifier =
Development Status :: 1 - Planning
License :: OSI Approved :: ISC License (ISCL)
Operating System :: OS Independent
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.4
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Topic :: Software Development :: Libraries :: Python Modules

[options]
zip_safe = true
python_requires = >=2.6,!=3.0,!=3.1,!=3.2,!=3.3
setup_requires = setuptools>=36.2.2
python_requires = >=3.7
setup_requires = setuptools>=36.6.2
install_requires =
six
tomlkit

[options.extras_require]
Expand Down
18 changes: 6 additions & 12 deletions src/plette/lockfiles.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
from __future__ import unicode_literals

import json
import numbers

try:
import collections.abc as collections_abc
except ImportError:
import collections as collections_abc
import collections.abc as collections_abc

import six

from .models import DataView, Meta, PackageCollection

Expand All @@ -28,14 +22,14 @@ def __init__(self):

def encode(self, obj):
content = super(_LockFileEncoder, self).encode(obj)
if not isinstance(content, six.text_type):
if not isinstance(content, str):
content = content.decode("utf-8")
content += "\n"
return content

def iterencode(self, obj):
for chunk in super(_LockFileEncoder, self).iterencode(obj):
if not isinstance(chunk, six.text_type):
if not isinstance(chunk, str):
chunk = chunk.decode("utf-8")
yield chunk
yield "\n"
Expand All @@ -53,15 +47,15 @@ def iterencode(self, obj):
def _copy_jsonsafe(value):
"""Deep-copy a value into JSON-safe types.
"""
if isinstance(value, six.string_types + (numbers.Number,)):
if isinstance(value, (str, numbers.Number)):
return value
if isinstance(value, collections_abc.Mapping):
return {six.text_type(k): _copy_jsonsafe(v) for k, v in value.items()}
return {str(k): _copy_jsonsafe(v) for k, v in value.items()}
if isinstance(value, collections_abc.Iterable):
return [_copy_jsonsafe(v) for v in value]
if value is None: # This doesn't happen often for us.
return None
return six.text_type(value)
return str(value)


class Lockfile(DataView):
Expand Down
6 changes: 2 additions & 4 deletions src/plette/models/packages.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import six

from .base import DataView


Expand All @@ -26,7 +24,7 @@ def validate(cls, data):
return super(Package, cls).validate({"__package__": data})

def __getattr__(self, key):
if isinstance(self._data, six.string_types):
if isinstance(self._data, str):
if key == "version":
return self._data
raise AttributeError(key)
Expand All @@ -39,7 +37,7 @@ def __getattr__(self, key):
def __setattr__(self, key, value):
if key == "_data":
super(Package, self).__setattr__(key, value)
elif key == "version" and isinstance(self._data, six.string_types):
elif key == "version" and isinstance(self._data, str):
self._data = value
else:
self._data[key] = value
4 changes: 1 addition & 3 deletions src/plette/models/scripts.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import re
import shlex

import six

from .base import DataView


Expand All @@ -23,7 +21,7 @@ class Script(DataView):

def __init__(self, data):
super(Script, self).__init__(data)
if isinstance(data, six.string_types):
if isinstance(data, str):
data = shlex.split(data)
self._parts = [data[0]]
self._parts.extend(data[1:])
Expand Down
5 changes: 1 addition & 4 deletions src/plette/pipfiles.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from __future__ import unicode_literals

import hashlib
import json

import six
import tomlkit

from .models import (
Expand Down Expand Up @@ -84,7 +81,7 @@ def get_hash(self):
"develop": self._data.get("dev-packages", {}),
}
content = json.dumps(data, sort_keys=True, separators=(",", ":"))
if isinstance(content, six.text_type):
if isinstance(content, str):
content = content.encode("utf-8")
return Hash.from_hash(hashlib.sha256(content))

Expand Down