Skip to content

Commit

Permalink
Merge pull request #19 from PH-KDX/3.11-support
Browse files Browse the repository at this point in the history
v0.7.1
  • Loading branch information
PH-KDX authored Feb 21, 2023
2 parents 3525b70 + 23251f3 commit bc45cb5
Show file tree
Hide file tree
Showing 16 changed files with 155 additions and 108 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
pip install build wheel twine
- name: Build
run: |
python -m build
-name: Publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/* --skip-existing
2 changes: 1 addition & 1 deletion .github/workflows/test_and_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
unittests:
strategy:
matrix:
python-version: [ '3.8', '3.9', '3.10']
python-version: [ '3.8', '3.9', '3.10', '3.11']
runs-on: ubuntu-latest

name: Unit tests, Python ${{ matrix.python-version }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ dist

docs/build

build/

ignore/

venv
Expand Down
30 changes: 30 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python
build:
os: ubuntu-22.04
tools:
python: "3.11"

# Declare the Python requirements required to build docs
python:
install:
- method: pip
path: .
extra_requirements:
- docs

# Build documentation in the docs/ directory with Sphinx
sphinx:
builder: html
configuration: docs/source/conf.py

# Build PDF & ePub
formats:
- epub
- pdf
23 changes: 23 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Changelog
--------------------

0.7.1
^^^^^^^^^^^^^^^^^^^^
This is a minor update, which adds support for Python 3.11 and moves the package configuration
from setup.py to pyproject.toml. No breaking changes have been introduced. A bug has been fixed
which was causing aiohttp to crash on null parameters, and a bug in the quickstart example has
been fixed.

0.7.0
^^^^^^^^^^^^^^^^^^^^
This is another complete rewrite of the library, in which it is entirely converted to async.
This should mean faster execution of parallel requests, and no blocking when called from
another async library. Support for Python 3.7 has been dropped in this release. Python 3.11
is not yet supported as aiohttp does not yet support Python 3.11 at the time of release.

0.6.0
^^^^^^^^^^^^^^^^^^^^
This is a complete rewrite of the library, which moves functions out of classes.
This does have the side effect of requiring a key to be passed into every authenticated request,
instead of being passed into a class once on initialisation. The rewrite also incorporates
several small bugfixes, and changes the test environment from unittest to pytest.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img src="https://raw.githubusercontent.com/PH-KDX/flightplandb-py/feature/artwork/png/240x240.png" alt="FlightPlanDB-py logo">
<img src="https://raw.githubusercontent.com/PH-KDX/flightplandb-py/main/artwork/png/240x240.png" alt="FlightPlanDB-py logo">
</p>

# FlightplanDB-py
Expand All @@ -22,4 +22,4 @@ The library can be installed from PyPi using `pip install flightplandb`;
the PyPi installation page link is [here](https://pypi.org/project/flightplandb/). For more details, see the Installation section of the documentation.

## Changelog
Before upgrading to a newer version, please read the appropriate changelog for your upgrade [here](https://flightplandb-py.readthedocs.io/en/stable/user/changelog.html).
Before upgrading to a newer version, please read the appropriate changelog for your upgrade [here](https://github.com/PH-KDX/flightplandb-py/blob/main/CHANGELOG.rst).
8 changes: 4 additions & 4 deletions docs/source/_static/css/colourscheme.css
Original file line number Diff line number Diff line change
Expand Up @@ -3049,10 +3049,10 @@
}
html.writer-html4 .rst-content dl:not(.docutils) > dt,
html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) > dt {
background-color: rgb(32, 35, 36);
background-color: rgb(32, 35, 36) !important;
background-image: none;
color: rgb(84, 164, 217);
border-top-color: rgb(28, 89, 128);
color: rgb(84, 164, 217) !important;
border-top-color: rgb(28, 89, 128) !important;
}
html.writer-html4 .rst-content dl:not(.docutils) > dt::before,
html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) > dt::before {
Expand Down Expand Up @@ -3104,7 +3104,7 @@
background-color: rgb(32, 35, 36); background-image: none;
}
html.writer-html4 .rst-content dl:not(.docutils) .descclassname, html.writer-html4 .rst-content dl:not(.docutils) .descname, html.writer-html4 .rst-content dl:not(.docutils) .sig-name, html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) .descclassname, html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) .descname, html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) .sig-name {
color: rgb(255, 255, 255);
color: rgb(255, 255, 255) !important;
}
span[id*="MathJax-Span"] {
color: rgb(192, 186, 178);
Expand Down
3 changes: 2 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
import os
import sys
from flightplandb import __version__
sys.path.insert(0, os.path.abspath('../../'))


Expand All @@ -21,7 +22,7 @@
author = 'PH-KDX'

# The full version, including alpha/beta/rc tags
release = '0.7.0'
release = __version__
# readthedocs.io insists on the version field being filled for epub builds
version = release

Expand Down
19 changes: 3 additions & 16 deletions docs/source/user/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
Changelog
--------------------

0.7.0
^^^^^^^^^^^^^^^^^^^^
This is another complete rewrite of the library, in which it is entirely converted to async.
This should mean faster execution of parallel requests, and no blocking when called from
another async library. Support for Python 3.7 has been dropped in this release. Python 3.11
is not yet supported as aiohttp does not yet support Python 3.11 at the time of release.

0.6.0
^^^^^^^^^^^^^^^^^^^^
This is a complete rewrite of the library, which moves functions out of classes.
This does have the side effect of requiring a key to be passed into every authenticated request,
instead of being passed into a class once on initialisation. The rewrite also incorporates
several small bugfixes, and changes the test environment from unittest to pytest.
.. include:: ../../../CHANGELOG.rst
..
reference to changelog outside of docs directory, with thanks to https://stackoverflow.com/a/17217041
4 changes: 3 additions & 1 deletion docs/source/user/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ request limit from 100 to 2500.
resp = fpdb.plan.search(
plan_query=query,
include_route=True,
sort="distance"
sort="distance",
limit=3,
key=API_KEY
)
Expand All @@ -54,6 +54,8 @@ request limit from 100 to 2500.
# then check remaining requests by subtracting the requests made from the total limit
print((await fpdb.api.limit_cap())-(await fpdb.api.limit_used()))
asyncio.run(main())
Try saving this program in a file in your project directory and running it.
Experiment around with different commands to get a feel for the library.
Expand Down
56 changes: 56 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "flightplandb"
authors = [
{name = "PH-KDX", email = "[email protected]"},
]
description = "Python wrapper for the Flight Plan Database API"
readme = "README.md"
requires-python = ">=3.8"
license = {text = "GPL v3"}

classifiers = [
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Intended Audience :: Developers",
"Natural Language :: English",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Operating System :: OS Independent",
"Topic :: Internet",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Utilities",
"Topic :: Games/Entertainment :: Simulation",
]
dependencies = [
"aiohttp >= 3.8.4; python_version >= '3.11'",
"aiohttp >= 3.5.2; python_version < '3.11'",
"python-dateutil~=2.8.2",
]
dynamic = ["version"]

[project.optional-dependencies]
docs = ["Sphinx==6.1.3", "sphinx-rtd-theme==1.2.0"]
test = ["pytest~=7.2.1", "pytest-socket~=0.6.0", "pytest-asyncio~=0.20.3"]

[project.urls]
"Homepage" = "https://github.com/PH-KDX/flightplandb-py/"
"Documentation" = "https://flightplandb-py.readthedocs.io/"
"Issue tracker" = "https://github.com/PH-KDX/flightplandb-py/issues"
"Changelog" = "https://github.com/PH-KDX/flightplandb-py/blob/main/CHANGELOG.rst"

[tool.setuptools.dynamic]
version = {attr = "flightplandb.__version__"}

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

[tool.pytest.ini_options]
addopts = "-vv --disable-socket"
asyncio_mode = "auto"
3 changes: 0 additions & 3 deletions pytest.ini

This file was deleted.

2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

69 changes: 0 additions & 69 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/flightplandb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


# Version of the flightplandb package
__version__ = "0.7.0"
__version__ = "0.7.1"

from . import (
internal, exceptions, datatypes,
Expand Down
28 changes: 23 additions & 5 deletions src/flightplandb/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,18 @@ async def request(
params = {}

# the API only takes "true" or "false", not True or False
# additionally, aiohttp refuses to pass in a boolean or nonetype in the params
_null_keys = []
for _key, _value in params.items():
if _value in (True, False):
params[_key] = json.dumps(_value)
elif _value is None:
_null_keys.append(_key)

# popping null keys directly when iterating over the dictionary would cause
# the dictionary to change size while iterating, which would crash
for _key in _null_keys:
params.pop(_key)

# convert the API content return_format to an HTTP Accept type
try:
Expand Down Expand Up @@ -417,11 +426,6 @@ async def getiter(
if not params:
params = {}

# the API only takes "true" or "false", not True or False
for key, value in params.items():
if value in (True, False):
params[key] = json.dumps(value)

valid_sort_orders = ["created", "updated", "popularity", "distance"]
if sort not in valid_sort_orders:
raise ValueError(
Expand All @@ -438,6 +442,20 @@ async def getiter(
# initially no results have been fetched yet
num_results = 0

# the API only takes "true" or "false", not True or False
# additionally, aiohttp refuses to pass in a boolean or nonetype in the params
_null_keys = []
for _key, _value in params.items():
if _value in (True, False):
params[_key] = json.dumps(_value)
elif _value is None:
_null_keys.append(_key)

# popping null keys directly when iterating over the dictionary would cause
# the dictionary to change size while iterating, which would crash
for _key in _null_keys:
params.pop(_key)

async with aiohttp.ClientSession() as session:
async with session.get(
url=url,
Expand Down

0 comments on commit bc45cb5

Please sign in to comment.