Skip to content

Commit

Permalink
Merge pull request #43 from dcbaker/remove-python2
Browse files Browse the repository at this point in the history
Remove python2
  • Loading branch information
dcbaker authored May 14, 2024
2 parents 84f7697 + d4de91c commit 42fe8a2
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 234 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ jobs:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel sphinx sphinx_rtd_theme
- name: Build docs
run: sphinx-build -W -b html docs/source docs/build
run: sphinx-build -W -b html docs/source docs/build
7 changes: 1 addition & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Six is needed for jsonstreams, as nothing else depends on it anymore
pip install wheel pylint mypy pycodestyle pydocstyle six
pip install wheel pylint mypy pycodestyle pydocstyle
- name: Lint with pylint
run: |
pylint jsonstreams --rcfile=pylintrc --reports=n
- name: Lint with mypy
run: |
mypy -p jsonstreams
mypy -p tests
- name: Lint with pycodestyle
run: |
pycodestyle jsonstreams
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7, 3.6, 3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
Expand All @@ -24,10 +24,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest six
- name: Install python2 dependencies
if: ${{ matrix.python-version == 2.7 }}
run: pip install enum34
pip install pytest
- name: Test with pytest
run: |
pytest tests
Expand Down
9 changes: 4 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ skip_tags: true
shallow_clone: true
clone_depth: 100

only_commits:
files:
- '**/*py'

environment:
matrix:
- PYTHON: C:\Python27
TOXENV: "py27"

- PYTHON: C:\Python36
TOXENV: "py36"
Expand All @@ -22,9 +24,6 @@ environment:
- PYTHON: C:\Python38
TOXENV: "py38"

- PYTHON: C:\Python38
TOXENV: "py38"

init:
- ps: echo $env:TOXENV
- ps: ls C:\Python*
Expand Down
10 changes: 10 additions & 0 deletions docs/source/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changes
next
-----

- Drop support for python 2.x
- Drop enum34 requirement
- Drop use of six package

0.6.0
------

Expand All @@ -29,6 +33,11 @@ Bug Fixes:
0.5.0
------

New Features

- Drop support for python 2
- Drop six requirement

Bug Fixes:

- Fix a bug that prevents the Stream class from producing proper compact JSON output
Expand All @@ -38,6 +47,7 @@ Bug Fixes:
- flush the fd before closing the Stream
(`#24 <https://github.com/dcbaker/jsonstreams/issues/24>`_)


0.4.3
------

Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
Expand Down
27 changes: 11 additions & 16 deletions jsonstreams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,13 @@
... a.iterwrite(range(5))
"""

import enum
import functools
import warnings
try:
import simplejson as json # type: ignore
except ImportError:
import json # type: ignore
try:
import enum
except ImportError:
import enum34 as enum # type: ignore

import six

__all__ = (
'InvalidTypeError',
Expand Down Expand Up @@ -119,7 +114,7 @@ class InvalidTypeError(JSONStreamsError):
"""


class BaseWriter(object):
class BaseWriter:
"""Private class for writing things."""

__slots__ = ('fd', 'indent', 'baseindent', 'encoder', 'pretty', 'comma',
Expand Down Expand Up @@ -199,7 +194,7 @@ def write_key(self, key):
This will enforce that a key must be a string type, since that's a
requirement of JSON.
"""
if not isinstance(key, (six.text_type, six.binary_type)):
if not isinstance(key, (str, bytes)):
raise InvalidTypeError('Only string or bytes types can be used as '
'keys in JSON objects')
self.write_all(self.encoder.iterencode(key), indent=self.indent)
Expand Down Expand Up @@ -290,7 +285,7 @@ def _raise(exc, *args, **kwargs): # pylint: disable=unused-argument
raise exc


class Open(object):
class Open:
"""A helper to allow subelements to be used as context managers."""

__slots__ = ('__inst', '__callback', 'subarray', 'subobject')
Expand All @@ -316,7 +311,7 @@ def __exit__(self, etype, evalue, traceback):
self.close()


class _CacheChild(object):
class _CacheChild:
"""Object that hides public methods while a child is opened.
It does this by shadowing them with a function that raises an exception
Expand All @@ -332,15 +327,15 @@ def __init__(self, inst, **kwargs):

func = functools.partial(_raise, ModifyWrongStreamError(
'Cannot modify a stream while a child stream is opened'))
for k in six.iterkeys(kwargs):
for k in kwargs:
setattr(inst, k, func)

def restore(self):
for k, v in six.iteritems(self.cached):
for k, v in self.cached.items():
setattr(self.inst, k, v)


class Object(object):
class Object:
"""A streaming array representation."""

def __init__(self, fd, indent, baseindent, encoder, _indent=False,
Expand Down Expand Up @@ -427,7 +422,7 @@ def __exit__(self, etype, evalue, traceback):
self.close()


class Array(object):
class Array:
"""A streaming array representation."""

def __init__(self, fd, indent, baseindent, encoder, _indent=False,
Expand Down Expand Up @@ -530,7 +525,7 @@ class Type(enum.Enum):
ARRAY = 4


class Stream(object):
class Stream:
"""A JSON stream object.
This object is the "root" object for the stream. It handles opening and
Expand Down Expand Up @@ -578,7 +573,7 @@ def __init__(self, jtype, filename=None, fd=None, indent=None,
if fd and filename:
raise RuntimeError(
'Must pass exactly one of "filename" or "fd" (got both)')
self.__fd = fd or open(filename, 'w')
self.__fd = fd or open(filename, 'w') # pylint: disable=consider-using-with,unspecified-encoding

# If we didn't open the file, we need to check if we own the fd, or
# not.
Expand Down
97 changes: 0 additions & 97 deletions jsonstreams/__init__.pyi

This file was deleted.

Loading

0 comments on commit 42fe8a2

Please sign in to comment.