Skip to content

Remove duplicate read_text without orjson #348

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

Merged
merged 2 commits into from
May 20, 2021
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
11 changes: 11 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,14 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
fail_ci_if_error: false
vanilla:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Install without orjson
run: pip install '.[validation]'
- name: Run unittests
run: python -m unittest discover tests
2 changes: 0 additions & 2 deletions .style.yapf

This file was deleted.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

### Changed

### Fixed

- Reading json without orjson ([#348](https://github.com/stac-utils/pystac/pull/348))

### Remove

## [1.0.0-beta.1]
Expand Down
4 changes: 2 additions & 2 deletions pystac/stac_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

# Use orjson if available
try:
import orjson
import orjson # type: ignore
except ImportError:
orjson = None

Expand Down Expand Up @@ -77,7 +77,7 @@ def _json_loads(self, txt: str, source: Union[str, "Link_Type"]) -> Dict[str, An
if orjson is not None:
return orjson.loads(txt)
else:
return json.loads(self.read_text(txt))
return json.loads(txt)

def _json_dumps(
self, json_dict: Dict[str, Any], source: Union[str, "Link_Type"]
Expand Down
2 changes: 1 addition & 1 deletion scripts/format
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fi
function usage() {
echo -n \
"Usage: $(basename "$0")
Format code with yapf
Format code with black
"
}

Expand Down
6 changes: 6 additions & 0 deletions tests/test_stac_io.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest
import warnings

import pystac
from pystac.stac_io import STAC_IO
from tests.utils import TestCases

Expand All @@ -18,3 +19,8 @@ def test_stac_io_issues_warnings(self):
# Verify some things
self.assertEqual(len(w), 1)
self.assertTrue(issubclass(w[-1].category, DeprecationWarning))

def test_read_text(self):
_ = pystac.read_file(
TestCases.get_path("data-files/collections/multi-extent.json")
)