Skip to content

Commit

Permalink
Transfer first version from DSS repo
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminPelletier committed Oct 10, 2022
1 parent de808d1 commit 45dd43f
Show file tree
Hide file tree
Showing 9 changed files with 558 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Based on https://github.com/denkiwakame/py-tiny-pkg/blob/main/.github/workflows/pub.yml
# To create a release, see https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository

name: publish

on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: setup-python
uses: actions/setup-python@v3
with:
python-version: "3.x"
architecture: "x64"
- name: install pypa/build
run: >-
python -m
pip install
build
--user
- name: build sdist(tarball) and bdist(wheel) to dist/
run: >- # = python -m build . works the same way by default
python -m
build
--sdist
--wheel
--outdir dist/
- name: publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
55 changes: 55 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Based on https://github.com/denkiwakame/py-tiny-pkg/blob/main/.github/workflows/test.yml

name: package

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
install-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.8", "3.9"]
max-parallel: 3
name: Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
- name: setup-python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
architecture: "x64"
- name: confirm pip version
run: pip --version
- name: installation
run: pip install .[dev]
- name: test
run: python -m pytest --cov
editable-install-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.8"]
max-parallel: 3
name: Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
- name: setup-python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
architecture: "x64"
- name: confirm pip version
run: pip --version
- name: installation
run: pip install -e .[dev]
- name: test
run: python -m pytest --cov
38 changes: 38 additions & 0 deletions .github/workflows/test_publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Based on https://github.com/denkiwakame/py-tiny-pkg/blob/main/.github/workflows/testpub.yml

name: publish-test

on:
push:
tags:
- "*"

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: setup-python
uses: actions/setup-python@v3
with:
python-version: "3.x"
architecture: "x64"
- name: install pypa/build
run: >-
python -m
pip install
build
--user
- name: build sdist(tarball) and bdist(wheel) to dist/
run: >- # = python -m build . works the same way by default
python -m
build
--sdist
--wheel
--outdir dist/
- name: publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Contributions to this repository are managed via the same process as for the [dss repository](https://github.com/interuss/dss/CONTRIBUTING.md).
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
# implicitdict

This library primarily provides the `ImplicitDict` base class which enables the inheriting class to implicitly be treated like a `dict` with entries corresponding to the fields of the inheriting class. Simple example:

```python
class MyData(ImplicitDict):
foo: str
bar: int = 0
baz: Optional[float]

data: MyData = ImplicitDict.parse({'foo': 'asdf', 'bar': 1}, MyData)
assert json.dumps(data) == '{"foo": "asdf", "bar": 1}'
```

See [class documentation for `ImplicitDict`](src/implicitdict/__init__.py) and [test_normal_usage.py](tests/test_normal_usage.py) for more information.
47 changes: 47 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Based on https://github.com/denkiwakame/py-tiny-pkg/blob/main/pyproject.toml

[build-system]
requires = [
"setuptools>=64",
"wheel", # for bdist package distribution
"setuptools_scm>=6.4", # for automated versioning
]

build-backend = "setuptools.build_meta"

[tool.setuptools]
include-package-data = true
package-dir = { "" = "src" }

[tool.setuptools.packages.find]
where = ["src"]
namespaces = true

[tool.setuptools_scm]
write_to = "src/implicitdict/_version.py"

[project]
name = "implicitdict"
dynamic = ["version"]
authors = [
{ name="InterUSS Platform", email="[email protected]" },
]
description = "ImplicitDict base class that turns a subclass into a dict indexing attributes, making [de]serialization easy for complex typing-annotated data types."
readme = "README.md"
license = { file = "LICENSE.md" }
requires-python = ">=3.8"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
]
dependencies = ["arrow", "pytimeparse"]
[project.optional-dependencies]
dev = ["pytest==5.0.0", "pytest-cov[all]", "black==21.10b0"]
[project.urls]
"Homepage" = "https://github.com/interuss/implicitdict"
"Bug Tracker" = "https://github.com/interuss/implicitdict/issues"

[tool.black]
target-version = ['py39']
line-length = 120
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
arrow==1.2.3
pytimeparse==1.1.8
Loading

0 comments on commit 45dd43f

Please sign in to comment.