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

Setup upgrade #2

Merged
merged 48 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
45356f6
upgrade the versioneer to the 0.29 version
yafshar Mar 9, 2024
b40b08c
Upgrade the distribution packaging
yafshar Mar 9, 2024
f478d30
Update the action version
yafshar Mar 9, 2024
feed6cc
kim_edn.tool read infile before writing to outfile
yafshar Mar 10, 2024
1747a25
Minor fix
yafshar Mar 10, 2024
ba971a7
Remove argparse.FileType
yafshar Mar 10, 2024
a01f47f
Use super() in subclass example
yafshar Mar 10, 2024
f72bc2a
Remove the str.format when unnecessary
yafshar Mar 10, 2024
cfefb6a
Fix the indentation
yafshar Mar 10, 2024
df5694a
Remove unused import
yafshar Mar 10, 2024
54ca60f
Remove unused import
yafshar Mar 10, 2024
b2aef06
Use the locally defined variable
yafshar Mar 10, 2024
9f635de
Fix the bare 'except'
yafshar Mar 10, 2024
3cd0429
Fix the 2 blank lines before class
yafshar Mar 10, 2024
2d827e2
Fix the flex complexity and max-line-length expectation for kim-edn
yafshar Mar 10, 2024
adc636d
Fixes module level import & blank line warning
yafshar Mar 10, 2024
ca6c375
blank line warning
yafshar Mar 10, 2024
d1d9aa8
Remove unused import
yafshar Mar 10, 2024
20ca5b6
Correct the format
yafshar Mar 10, 2024
f51598c
Correct the format
yafshar Mar 10, 2024
9e973ba
Fix the indentation
yafshar Mar 10, 2024
4db7a30
Fix the complexity for kim-edn
yafshar Mar 10, 2024
7d44bda
minor fix
yafshar Mar 10, 2024
61fcf83
test
yafshar Mar 10, 2024
b9e7d5e
upgrade codecov
yafshar Mar 10, 2024
fbabbd5
Fix the str object has no attribute 'open'
yafshar Mar 11, 2024
8c64364
Add indent option to the arguments
yafshar Mar 11, 2024
a1683d9
add extra options for the tool module
yafshar Mar 12, 2024
83272f8
Add new test for tool module
yafshar Mar 12, 2024
699890d
Remove appveyor. GitHub actions cover windows
yafshar Mar 12, 2024
ed8da98
Update the README
yafshar Mar 12, 2024
b1fbf17
fix the indentation
yafshar Mar 12, 2024
a70c4f6
skip test for not supported Python version
yafshar Mar 12, 2024
9518f64
Update the test tool
yafshar Mar 12, 2024
d99c324
Update the import
yafshar Mar 12, 2024
8f07f59
Add extra test to cover missing object
yafshar Mar 13, 2024
abebcd3
Add xetra case to cover a corner case
yafshar Mar 13, 2024
696eb29
Add extra tests
yafshar Mar 13, 2024
6ee121e
Update the Python version for coverage action
yafshar Mar 13, 2024
f788047
Update the publish action
yafshar Mar 13, 2024
00278a0
Update the package action
yafshar Mar 13, 2024
05fb4f7
Update the interface
yafshar Mar 14, 2024
2532e4a
fix the indented line issue
yafshar Mar 14, 2024
f1202d7
Add extra tests to cover corner cases
yafshar Mar 14, 2024
6234b3b
Remove trailing whitespace
yafshar Mar 14, 2024
df34018
Add reduce test for pickling
yafshar Mar 14, 2024
78ccbd1
Add skip test for Not supported Python
yafshar Mar 14, 2024
dc7c1b8
Fix the missing letter
yafshar Mar 14, 2024
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
22 changes: 0 additions & 22 deletions .appveyor.yml

This file was deleted.

19 changes: 10 additions & 9 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
exclude:
- os: windows-latest
python-version: '3.6'
python-version: [3.8, 3.9, '3.10', 3.11, 3.12]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand All @@ -29,13 +26,17 @@ jobs:
# 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
flake8 . --count --exit-zero --max-complexity=51 --max-line-length=1023 --statistics
- name: Test with unittest
run: |
python -m tests
coverage run -m tests
- name: Post Coverage
uses: codecov/codecov-action@v1
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9'
uses: codecov/codecov-action@v4
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
with:
verbose: true
fail_ci_if_error: false
flags: unittests
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
20 changes: 10 additions & 10 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME_OPENKIM }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD_OPENKIM }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1.8
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD_OPENKIM }}
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
include versioneer.py
include kim_edn/_version.py
45 changes: 33 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# KIM-EDN encoder and decoder

[![Python package](https://github.com/openkim/kim-edn/workflows/Python%20package/badge.svg)](https://github.com/openkim/kim-edn/actions)
[![Windows Build status](https://ci.appveyor.com/api/projects/status/3amxmm9j5v8eykn2?svg=true)](https://ci.appveyor.com/project/yafshar/kim-edn)
[![codecov](https://codecov.io/gh/openkim/kim-edn/branch/master/graph/badge.svg)](https://codecov.io/gh/openkim/kim-edn)
[![Anaconda-Server Badge](https://img.shields.io/conda/vn/conda-forge/kim-edn.svg)](https://anaconda.org/conda-forge/kim-edn)
[![PyPI](https://img.shields.io/pypi/v/kim-edn.svg)](https://pypi.python.org/pypi/kim-edn)
Expand Down Expand Up @@ -297,24 +296,50 @@ reference.
Installing `kim-edn` from the `conda-forge` channel can be achieved by adding
`conda-forge` to your channels with:

```sh
```
conda config --add channels conda-forge
conda config --set channel_priority strict
```

Once the `conda-forge` channel has been enabled, `kim-edn` can be installed
with:
with `conda`:

```sh
```
conda install kim-edn
```

or with `mamba`:

```
mamba install kim-edn
```

It is possible to list all of the versions of `kim-edn` available on your
platform with:
platform with `conda`:

```sh
```
conda search kim-edn --channel conda-forge
```

or with `mamba`:

```
mamba search kim-edn --channel conda-forge
```

Alternatively, `mamba repoquery` may provide more information:

```
# Search all versions available on your platform:
mamba repoquery search kim-edn --channel conda-forge
# List packages depending on `kim-edn`:
mamba repoquery whoneeds kim-edn --channel conda-forge
# List dependencies of `kim-edn`:
mamba repoquery depends kim-edn --channel conda-forge
```

## References

This module has been adapted and updated from the
Expand All @@ -323,13 +348,9 @@ This module has been adapted and updated from the

## Copyright

Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Python Software
Foundation;\
All Rights Reserved
Copyright © 2001-2024 Python Software Foundation. All rights reserved.

Copyright (c) 2019-2021, Regents of the University of Minnesota.\
All Rights Reserved
Copyright (c) 2019-2024, Regents of the University of Minnesota. All Rights Reserved.

## Contributing

Expand Down
47 changes: 18 additions & 29 deletions kim_edn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@
>>> def encode_complex(obj):
... if isinstance(obj, complex):
... return [obj.real, obj.imag]
... msg = 'Object of type {} is not '.format(obj.__class__.__name__)
... msg += 'KIM-EDN serializable'
... msg = f'Object of type {obj.__class__.__name__} is not KIM-EDN serializable'
... raise TypeError(msg)
...
>>> kim_edn.dumps(2 + 1j, default=encode_complex)
Expand Down Expand Up @@ -143,9 +142,7 @@
}
}

"""

"""
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Python Software Foundation;
All Rights Reserved
Expand Down Expand Up @@ -296,7 +293,7 @@ def detect_encoding(b):
return 'utf-8'


def load(fp, *, cls=None, parse_float=None, parse_int=None, parse_constant=None,
def load(fp, *, cls=None, parse_float=None, parse_int=None,
object_hook=None, object_pairs_hook=None):
r"""Deserialize ``fp``.

Expand Down Expand Up @@ -334,13 +331,12 @@ def load(fp, *, cls=None, parse_float=None, parse_int=None, parse_constant=None,
cls=cls,
parse_float=parse_float,
parse_int=parse_int,
parse_constant=parse_constant,
object_hook=object_hook,
object_pairs_hook=object_pairs_hook)


def loads(s, *, cls=None, parse_float=None, parse_int=None,
parse_constant=None, object_hook=None, object_pairs_hook=None):
object_hook=None, object_pairs_hook=None):
r"""Deserialize ``s``.

Deserialize ``s`` (a ``str``, ``bytes`` or ``bytearray`` instance
Expand All @@ -367,11 +363,6 @@ def loads(s, *, cls=None, parse_float=None, parse_int=None,
int(num_str). This can be used to use another datatype or parser
for EDN integers (e.g. float).

``parse_constant``, if specified, will be called with one of the
following strings: -Infinity, Infinity, NaN.
This can be used to raise an exception if invalid EDN numbers
are encountered.

To use a custom ``KIMEDNDecoder`` subclass, specify it with the ``cls``
kwarg; otherwise ``KIMEDNDecoder`` is used.

Expand All @@ -383,41 +374,39 @@ def loads(s, *, cls=None, parse_float=None, parse_int=None,
else:
if not isinstance(s, (bytes, bytearray)):
msg = 'the EDN object must be str, bytes or bytearray, '
msg += 'not {}'.format(s.__class__.__name__)
msg += f'not {s.__class__.__name__}'
raise TypeError(msg)

s = s.decode(detect_encoding(s), 'surrogatepass')

if (cls is None
and parse_float is None
and parse_int is None
and parse_constant is None
and object_hook is None and
object_pairs_hook is None):
return _default_decoder.decode(s)

if cls is None:
cls = KIMEDNDecoder

kw = {}
if parse_float is not None:
kw['parse_float'] = parse_float
if type(cls) is type:
kw = {}
if parse_float is not None:
kw['parse_float'] = parse_float

if parse_int is not None:
kw['parse_int'] = parse_int
if parse_int is not None:
kw['parse_int'] = parse_int

if parse_constant is not None:
kw['parse_constant'] = parse_constant
if object_hook is not None:
kw['object_hook'] = object_hook

if object_hook is not None:
kw['object_hook'] = object_hook
if object_pairs_hook is not None:
kw['object_pairs_hook'] = object_pairs_hook

if object_pairs_hook is not None:
kw['object_pairs_hook'] = object_pairs_hook
return cls(**kw).decode(s)

return cls(**kw).decode(s)
return cls.decode(s)


from ._version import get_versions
__version__ = get_versions()['version']
del get_versions
from . import _version # noqa: E402
__version__ = _version.get_versions()['version']
Loading