From 1e34bf4e7672b4508270e6c987afce23a90602b5 Mon Sep 17 00:00:00 2001 From: Vytautas Liuolia Date: Sun, 4 Jun 2023 20:45:06 +0200 Subject: [PATCH] docs: clean up newsfragments, aggregate 4.0.0 contributors so far (#2152) * docs: clean up newsfragments, aggregate contributors so far * chore: fix import order --- AUTHORS | 6 +++ docs/_newsfragments/2022.newandimproved.rst | 4 +- docs/_newsfragments/648.newandimproved.rst | 2 +- docs/api/routing.rst | 3 ++ docs/changes/4.0.0.rst | 9 +++++ falcon/routing/__init__.py | 1 + falcon/routing/converters.py | 5 ++- tools/add_contributors.py | 45 ++++++++++++++++----- 8 files changed, 60 insertions(+), 15 deletions(-) diff --git a/AUTHORS b/AUTHORS index affaac69d..96702c6a0 100644 --- a/AUTHORS +++ b/AUTHORS @@ -125,6 +125,12 @@ listed below by date of first contribution: * Christian Clauss (cclauss) * meetshah133 * Kai Chan (kaichan1201) +* Patryk KrawaczyƄski (nfsec) +* Jarek Kapica (jkapica) +* TigreModerata +* John G G (john-g-g) +* Aryan Iyappan (aryaniyaps) +* Eujin Ong (euj1n0ng) (et al.) diff --git a/docs/_newsfragments/2022.newandimproved.rst b/docs/_newsfragments/2022.newandimproved.rst index f0448fe8d..889e63621 100644 --- a/docs/_newsfragments/2022.newandimproved.rst +++ b/docs/_newsfragments/2022.newandimproved.rst @@ -1 +1,3 @@ -:class:`FloatConverter`:Modified existing IntConverter class and added FloatConverter class to convert string to float at runtime. \ No newline at end of file +Similar to the existing :class:`~falcon.routing.IntConverter`, a new +:class:`~falcon.routing.FloatConverter` has been added, allowing to convert +path segments to ``float``. diff --git a/docs/_newsfragments/648.newandimproved.rst b/docs/_newsfragments/648.newandimproved.rst index 9f97447a7..11aac79ae 100644 --- a/docs/_newsfragments/648.newandimproved.rst +++ b/docs/_newsfragments/648.newandimproved.rst @@ -1,2 +1,2 @@ -A new ``path`` :class:`converter <~falcon.routing.PathConverter>` +A new ``path`` :class:`converter ` capable of matching segments that include ``/`` was added. diff --git a/docs/api/routing.rst b/docs/api/routing.rst index d9cd6c454..b1b4ef36f 100644 --- a/docs/api/routing.rst +++ b/docs/api/routing.rst @@ -304,6 +304,9 @@ Built-in Converters .. autoclass:: falcon.routing.IntConverter :members: +.. autoclass:: falcon.routing.FloatConverter + :members: + .. autoclass:: falcon.routing.UUIDConverter :members: diff --git a/docs/changes/4.0.0.rst b/docs/changes/4.0.0.rst index b5b7c107b..457343885 100644 --- a/docs/changes/4.0.0.rst +++ b/docs/changes/4.0.0.rst @@ -23,11 +23,20 @@ Contributors to this Release Many thanks to all of our talented and stylish contributors for this release! +- `aryaniyaps `__ - `CaselIT `__ - `cclauss `__ +- `euj1n0ng `__ +- `jkapica `__ - `jkklapp `__ +- `john-g-g `__ +- `kaichan1201 `__ - `kgriffs `__ - `meetshah133 `__ - `mgorny `__ +- `mihaitodor `__ +- `nfsec `__ - `RioAtHome `__ +- `TigreModerata `__ +- `vgerak `__ - `vytas7 `__ diff --git a/falcon/routing/__init__.py b/falcon/routing/__init__.py index 56ea5bf87..9db1c4862 100644 --- a/falcon/routing/__init__.py +++ b/falcon/routing/__init__.py @@ -23,6 +23,7 @@ from falcon.routing.compiled import CompiledRouterOptions from falcon.routing.converters import BaseConverter from falcon.routing.converters import DateTimeConverter +from falcon.routing.converters import FloatConverter from falcon.routing.converters import IntConverter from falcon.routing.converters import PathConverter from falcon.routing.converters import UUIDConverter diff --git a/falcon/routing/converters.py b/falcon/routing/converters.py index 71b2782e9..0c35ddb1d 100644 --- a/falcon/routing/converters.py +++ b/falcon/routing/converters.py @@ -19,10 +19,10 @@ __all__ = ( 'BaseConverter', - 'IntConverter', 'DateTimeConverter', - 'UUIDConverter', 'FloatConverter', + 'IntConverter', + 'UUIDConverter', ) @@ -114,6 +114,7 @@ class FloatConverter(IntConverter): """Converts a field value to an float. Identifier: `float` + Keyword Args: min (float): Reject the value if it is less than this number. max (float): Reject the value if it is greater than this number. diff --git a/tools/add_contributors.py b/tools/add_contributors.py index 44c056d38..a25881a47 100755 --- a/tools/add_contributors.py +++ b/tools/add_contributors.py @@ -22,31 +22,39 @@ RST_CONTRIBUTOR_TEMPLATE = '- `{login} `__\n' -def get_latest_tag(): +def get_latest_tag(headers=None): uri = f'{FALCON_REPOSITORY_API}/tags' - for tag in requests.get(uri).json(): + resp = requests.get(uri, headers=headers) + resp.raise_for_status() + + for tag in resp.json(): if re.match(STABLE_RELEASE_TAG, tag['name']): return tag['name'], tag['commit']['sha'] -def iter_commits(until=None): +def iter_commits(until=None, headers=None): page = 1 uri = f'{FALCON_REPOSITORY_API}/commits' + resp = requests.get(uri, headers=headers) + resp.raise_for_status() - while commits := requests.get(uri).json(): + while commits := resp.json(): for commit in commits: - if until and commit['sha'] == until: + if until and commit['sha'].startswith(until): return yield commit page += 1 uri = f'{FALCON_REPOSITORY_API}/commits?page={page}' + resp = requests.get(uri, headers=headers) + resp.raise_for_status() -def aggregate_contributors(until=None): +def aggregate_contributors(until=None, headers=None): result = {} - for commit in iter_commits(until): - login = commit['author'].get('login') + for commit in iter_commits(until, headers=headers): + author = commit.get('author') or {} + login = author.get('login') if not login: continue if login in result: @@ -121,6 +129,14 @@ def main(): 'Optionally append them to AUTHORS and the active Towncrier template.' ) parser = argparse.ArgumentParser(description=description) + parser.add_argument( + '-a', '--auth', help='supply authentication token for GitHub requests' + ) + parser.add_argument( + '-t', + '--treeish', + help='aggregate since this commit (default: detect latest tag)', + ) parser.add_argument( '-n', '--dry-run', action='store_true', help='dry run: do not write any files' ) @@ -131,12 +147,19 @@ def main(): '--no-towncrier', action='store_true', help=f'do not write {towncrier_template}' ) args = parser.parse_args() + headers = {'Authorization': f'Bearer {args.auth}'} if args.auth else None + + if args.treeish: + commit = args.treeish + info = f'Contributors since commit {commit}):' + else: + tag, commit = get_latest_tag(headers=headers) + info = f'Contributors since the latest stable tag ({tag}):' - tag, commit = get_latest_tag() - contributors = aggregate_contributors(until=commit) + contributors = aggregate_contributors(until=commit, headers=headers) if contributors: - print(f'Contributors since the latest stable tag ({tag}):') + print(info) for login, name in contributors.items(): print(f' * {name} ({login})') else: