-
Notifications
You must be signed in to change notification settings - Fork 43
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 python 2.7 #60
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6b2c95d
!feat:remove python 2.7 support
cunla 4601845
fix:github action
cunla abad795
maint:add .idea to .gitignore
cunla 386646d
fix:install flake8
cunla a9ae880
remove twine
cunla 0bc72c8
remove twine
cunla c069534
remove twine
cunla cce7ed2
address comments
cunla File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,58 @@ | ||
name: Python package | ||
|
||
on: [push] | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
lint: | ||
name: "flake8 on code" | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.ref }} | ||
|
||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.12 | ||
allow-prereleases: true | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 | ||
- name: Run flake8 | ||
shell: bash | ||
run: | | ||
flake8 | ||
|
||
test: | ||
needs: [ lint ] | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["2.7", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] | ||
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12" ] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
allow-prereleases: true | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 pytest | ||
pip install coveralls | ||
# - name: Lint with flake8 | ||
# run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
pip install -r requirements-dev.txt | ||
|
||
- name: Test | ||
run: | | ||
make coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ dist | |
*.swp | ||
doc/_build | ||
*.egg-info | ||
.idea | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,38 +32,22 @@ | |
|
||
""" Identify specific nodes in a JSON document (RFC 6901) """ | ||
|
||
from __future__ import unicode_literals | ||
|
||
# Will be parsed by setup.py to determine package metadata | ||
__author__ = 'Stefan Kögl <[email protected]>' | ||
__version__ = '2.4' | ||
__version__ = '3.0.0' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any specific reason to go for 3 digits? Is there some standard to follow? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
__website__ = 'https://github.com/stefankoegl/python-json-pointer' | ||
__license__ = 'Modified BSD License' | ||
|
||
|
||
try: | ||
from itertools import izip | ||
str = unicode | ||
encode_str = lambda u: u.encode("raw_unicode_escape") | ||
except ImportError: # Python 3 | ||
izip = zip | ||
encode_str = lambda u: u | ||
|
||
try: | ||
from collections.abc import Mapping, Sequence | ||
except ImportError: # Python 3 | ||
from collections import Mapping, Sequence | ||
|
||
from itertools import tee, chain | ||
import re | ||
import copy | ||
|
||
import re | ||
from collections.abc import Mapping, Sequence | ||
from itertools import tee, chain | ||
|
||
_nothing = object() | ||
|
||
|
||
def set_pointer(doc, pointer, value, inplace=True): | ||
"""Resolves pointer against doc and sets the value of the target within doc. | ||
"""Resolves a pointer against doc and sets the value of the target within doc. | ||
With inplace set to true, doc is modified as long as pointer is not the | ||
root. | ||
|
@@ -145,7 +129,7 @@ def pairwise(iterable): | |
a, b = tee(iterable) | ||
for _ in b: | ||
break | ||
return izip(a, b) | ||
return zip(a, b) | ||
|
||
|
||
class JsonPointerException(Exception): | ||
|
@@ -259,12 +243,11 @@ def get_part(cls, doc, part): | |
else: | ||
raise JsonPointerException("Document '%s' does not support indexing, " | ||
"must be mapping/sequence or support __getitem__" % type(doc)) | ||
|
||
def get_parts(self): | ||
"""Returns the list of the parts. For example, JsonPointer('/a/b').get_parts() == ['a', 'b']""" | ||
|
||
return self.parts | ||
|
||
return self.parts | ||
|
||
def walk(self, doc, part): | ||
""" Walks one step in doc and returns the referenced part """ | ||
|
@@ -281,7 +264,7 @@ def walk(self, doc, part): | |
return doc[part] | ||
|
||
except IndexError: | ||
raise JsonPointerException("index '%s' is out of bounds" % (part, )) | ||
raise JsonPointerException("index '%s' is out of bounds" % (part,)) | ||
|
||
# Else the object is a mapping or supports __getitem__(so assume custom indexing) | ||
try: | ||
|
@@ -290,7 +273,6 @@ def walk(self, doc, part): | |
except KeyError: | ||
raise JsonPointerException("member '%s' not found in %s" % (part, doc)) | ||
|
||
|
||
def contains(self, ptr): | ||
""" Returns True if self contains the given ptr """ | ||
return self.parts[:len(ptr.parts)] == ptr.parts | ||
|
@@ -309,12 +291,11 @@ def join(self, suffix): | |
suffix_parts = suffix | ||
try: | ||
return JsonPointer.from_parts(chain(self.parts, suffix_parts)) | ||
except: | ||
except: # noqa E722 | ||
raise JsonPointerException("Invalid suffix") | ||
|
||
def __truediv__(self, suffix): # Python 3 | ||
def __truediv__(self, suffix): # Python 3 | ||
return self.join(suffix) | ||
__div__ = __truediv__ # Python 2 | ||
|
||
@property | ||
def path(self): | ||
|
@@ -342,10 +323,10 @@ def __hash__(self): | |
return hash(tuple(self.parts)) | ||
|
||
def __str__(self): | ||
return encode_str(self.path) | ||
return self.path | ||
|
||
def __repr__(self): | ||
return "JsonPointer(" + repr(self.path) + ")" | ||
return type(self).__name__ + "(" + repr(self.path) + ")" | ||
|
||
@classmethod | ||
def from_parts(cls, parts): | ||
|
@@ -362,5 +343,6 @@ def from_parts(cls, parts): | |
def escape(s): | ||
return s.replace('~', '~0').replace('/', '~1') | ||
|
||
|
||
def unescape(s): | ||
return s.replace('~1', '/').replace('~0', '~') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
wheel | ||
twine>=1.11.0 | ||
setuptools>=38.6.0 | ||
setuptools | ||
coverage | ||
flake8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
[bdist_wheel] | ||
universal = 1 | ||
|
||
[flake8] | ||
max-line-length = 120 | ||
exclude = .git,.tox,dist,doc,*egg,build,.venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
#!/usr/bin/env python | ||
|
||
from setuptools import setup | ||
import re | ||
import io | ||
import os.path | ||
import re | ||
|
||
from setuptools import setup | ||
|
||
dirname = os.path.dirname(os.path.abspath(__file__)) | ||
filename = os.path.join(dirname, 'jsonpointer.py') | ||
|
@@ -14,7 +15,7 @@ | |
PACKAGE = 'jsonpointer' | ||
|
||
MODULES = ( | ||
'jsonpointer', | ||
'jsonpointer', | ||
) | ||
|
||
AUTHOR_EMAIL = metadata['author'] | ||
|
@@ -26,10 +27,8 @@ | |
# Extract name and e-mail ("Firstname Lastname <[email protected]>") | ||
AUTHOR, EMAIL = re.match(r'(.*) <(.*)>', AUTHOR_EMAIL).groups() | ||
|
||
|
||
with open('README.md') as readme: | ||
long_description = readme.read() | ||
|
||
long_description = readme.read() | ||
|
||
CLASSIFIERS = [ | ||
'Development Status :: 5 - Production/Stable', | ||
|
@@ -38,8 +37,6 @@ | |
'License :: OSI Approved :: BSD License', | ||
'Operating System :: OS Independent', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 2', | ||
'Programming Language :: Python :: 2.7', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.7', | ||
'Programming Language :: Python :: 3.8', | ||
|
@@ -65,5 +62,5 @@ | |
py_modules=MODULES, | ||
scripts=['bin/jsonpointer'], | ||
classifiers=CLASSIFIERS, | ||
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*', | ||
) | ||
python_requires='>=3.7', | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's that? Never heard of it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jetbrains IDEs create this folder.
This just prevents from adding it accidently.