Skip to content

Commit 0bc437d

Browse files
authored
COH-29971 - Changes for supporting Python 3.8+ (#133)
These changes will bring down the Python version requirement for this project from 3.11+ to 3.8+
1 parent a564f6b commit 0bc437d

15 files changed

+416
-173
lines changed

.github/workflows/validate.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 Oracle Corporation and/or its affiliates.
1+
# Copyright 2022, 2024, Oracle Corporation and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at
33
# https://oss.oracle.com/licenses/upl.
44

@@ -8,15 +8,16 @@ on:
88
schedule:
99
- cron: "0 5 * * *"
1010
push:
11-
branches: [ main ]
11+
branches:
12+
- '*'
1213
pull_request:
1314
branches: [ main ]
1415
jobs:
1516
ci:
1617
strategy:
1718
fail-fast: false
1819
matrix:
19-
python-version: ["3.11.x"]
20+
python-version: ["3.8.x", "3.9.x", "3.10.x", "3.11.x"]
2021
poetry-version: ["1.5.0"]
2122
os: [ubuntu-latest]
2223
coherenceVersion:
@@ -81,8 +82,9 @@ jobs:
8182
${{ matrix.base-image }} \
8283
${{ matrix.profile }}
8384
- name: Archive server logs
85+
if: failure()
8486
uses: actions/upload-artifact@v4
8587
with:
86-
name: server-logs-${{ matrix.coherenceVersion }}
88+
name: server-logs-${{matrix.python-version}}-${{ matrix.coherenceVersion }}
8789
path: ./tests/utils/*.txt
8890
retention-days: 10

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022, 2023, Oracle and/or its affiliates.
1+
# Copyright (c) 2022, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at
33
# https://oss.oracle.com/licenses/upl.
44

@@ -8,7 +8,7 @@ exclude: \w*(_pb2)\w*
88

99
repos:
1010
- repo: https://github.com/pre-commit/pre-commit-hooks
11-
rev: v4.5.0
11+
rev: v4.6.0
1212
hooks:
1313
- id: trailing-whitespace
1414
- id: end-of-file-fixer
@@ -21,12 +21,12 @@ repos:
2121
- id: flake8
2222

2323
- repo: https://github.com/psf/black
24-
rev: 24.1.1
24+
rev: 24.4.0
2525
hooks:
2626
- id: black
2727

2828
- repo: https://github.com/pre-commit/mirrors-mypy
29-
rev: v1.8.0
29+
rev: v1.9.0
3030
hooks:
3131
- id: mypy
3232

THIRD_PARTY_LICENSES.txt

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,3 +737,220 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
737737
IN THE SOFTWARE.
738738

739739
----------------------------------------
740+
741+
742+
Package: typing-extensions
743+
License: PSF-2.0
744+
Requires: n/a
745+
Author: Guido van Rossum, Jukka Lehtosalo, Łukasz Langa, Michael Lee <levkivskyi@gmail.com?
746+
Home page: https://github.com/python/typing_extensions
747+
748+
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
749+
--------------------------------------------
750+
751+
1. This LICENSE AGREEMENT is between the Python Software Foundation
752+
("PSF"), and the Individual or Organization ("Licensee") accessing and
753+
otherwise using this software ("Python") in source or binary form and
754+
its associated documentation.
755+
756+
2. Subject to the terms and conditions of this License Agreement, PSF hereby
757+
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
758+
analyze, test, perform and/or display publicly, prepare derivative works,
759+
distribute, and otherwise use Python alone or in any derivative version,
760+
provided, however, that PSF's License Agreement and PSF's notice of copyright,
761+
i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
762+
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Python Software Foundation;
763+
All Rights Reserved" are retained in Python alone or in any derivative version
764+
prepared by Licensee.
765+
766+
3. In the event Licensee prepares a derivative work that is based on
767+
or incorporates Python or any part thereof, and wants to make
768+
the derivative work available to others as provided herein, then
769+
Licensee hereby agrees to include in any such work a brief summary of
770+
the changes made to Python.
771+
772+
4. PSF is making Python available to Licensee on an "AS IS"
773+
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
774+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
775+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
776+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
777+
INFRINGE ANY THIRD PARTY RIGHTS.
778+
779+
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
780+
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
781+
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
782+
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
783+
784+
6. This License Agreement will automatically terminate upon a material
785+
breach of its terms and conditions.
786+
787+
7. Nothing in this License Agreement shall be deemed to create any
788+
relationship of agency, partnership, or joint venture between PSF and
789+
Licensee. This License Agreement does not grant permission to use PSF
790+
trademarks or trade name in a trademark sense to endorse or promote
791+
products or services of Licensee, or any third party.
792+
793+
8. By copying, installing or otherwise using Python, Licensee
794+
agrees to be bound by the terms and conditions of this License
795+
Agreement.
796+
797+
798+
BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0
799+
-------------------------------------------
800+
801+
BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1
802+
803+
1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an
804+
office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the
805+
Individual or Organization ("Licensee") accessing and otherwise using
806+
this software in source or binary form and its associated
807+
documentation ("the Software").
808+
809+
2. Subject to the terms and conditions of this BeOpen Python License
810+
Agreement, BeOpen hereby grants Licensee a non-exclusive,
811+
royalty-free, world-wide license to reproduce, analyze, test, perform
812+
and/or display publicly, prepare derivative works, distribute, and
813+
otherwise use the Software alone or in any derivative version,
814+
provided, however, that the BeOpen Python License is retained in the
815+
Software, alone or in any derivative version prepared by Licensee.
816+
817+
3. BeOpen is making the Software available to Licensee on an "AS IS"
818+
basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
819+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND
820+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
821+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT
822+
INFRINGE ANY THIRD PARTY RIGHTS.
823+
824+
4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE
825+
SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS
826+
AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY
827+
DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
828+
829+
5. This License Agreement will automatically terminate upon a material
830+
breach of its terms and conditions.
831+
832+
6. This License Agreement shall be governed by and interpreted in all
833+
respects by the law of the State of California, excluding conflict of
834+
law provisions. Nothing in this License Agreement shall be deemed to
835+
create any relationship of agency, partnership, or joint venture
836+
between BeOpen and Licensee. This License Agreement does not grant
837+
permission to use BeOpen trademarks or trade names in a trademark
838+
sense to endorse or promote products or services of Licensee, or any
839+
third party. As an exception, the "BeOpen Python" logos available at
840+
http://www.pythonlabs.com/logos.html may be used according to the
841+
permissions granted on that web page.
842+
843+
7. By copying, installing or otherwise using the software, Licensee
844+
agrees to be bound by the terms and conditions of this License
845+
Agreement.
846+
847+
848+
CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1
849+
---------------------------------------
850+
851+
1. This LICENSE AGREEMENT is between the Corporation for National
852+
Research Initiatives, having an office at 1895 Preston White Drive,
853+
Reston, VA 20191 ("CNRI"), and the Individual or Organization
854+
("Licensee") accessing and otherwise using Python 1.6.1 software in
855+
source or binary form and its associated documentation.
856+
857+
2. Subject to the terms and conditions of this License Agreement, CNRI
858+
hereby grants Licensee a nonexclusive, royalty-free, world-wide
859+
license to reproduce, analyze, test, perform and/or display publicly,
860+
prepare derivative works, distribute, and otherwise use Python 1.6.1
861+
alone or in any derivative version, provided, however, that CNRI's
862+
License Agreement and CNRI's notice of copyright, i.e., "Copyright (c)
863+
1995-2001 Corporation for National Research Initiatives; All Rights
864+
Reserved" are retained in Python 1.6.1 alone or in any derivative
865+
version prepared by Licensee. Alternately, in lieu of CNRI's License
866+
Agreement, Licensee may substitute the following text (omitting the
867+
quotes): "Python 1.6.1 is made available subject to the terms and
868+
conditions in CNRI's License Agreement. This Agreement together with
869+
Python 1.6.1 may be located on the internet using the following
870+
unique, persistent identifier (known as a handle): 1895.22/1013. This
871+
Agreement may also be obtained from a proxy server on the internet
872+
using the following URL: http://hdl.handle.net/1895.22/1013".
873+
874+
3. In the event Licensee prepares a derivative work that is based on
875+
or incorporates Python 1.6.1 or any part thereof, and wants to make
876+
the derivative work available to others as provided herein, then
877+
Licensee hereby agrees to include in any such work a brief summary of
878+
the changes made to Python 1.6.1.
879+
880+
4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS"
881+
basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
882+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND
883+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
884+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT
885+
INFRINGE ANY THIRD PARTY RIGHTS.
886+
887+
5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
888+
1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
889+
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1,
890+
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
891+
892+
6. This License Agreement will automatically terminate upon a material
893+
breach of its terms and conditions.
894+
895+
7. This License Agreement shall be governed by the federal
896+
intellectual property law of the United States, including without
897+
limitation the federal copyright law, and, to the extent such
898+
U.S. federal law does not apply, by the law of the Commonwealth of
899+
Virginia, excluding Virginia's conflict of law provisions.
900+
Notwithstanding the foregoing, with regard to derivative works based
901+
on Python 1.6.1 that incorporate non-separable material that was
902+
previously distributed under the GNU General Public License (GPL), the
903+
law of the Commonwealth of Virginia shall govern this License
904+
Agreement only as to issues arising under or with respect to
905+
Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this
906+
License Agreement shall be deemed to create any relationship of
907+
agency, partnership, or joint venture between CNRI and Licensee. This
908+
License Agreement does not grant permission to use CNRI trademarks or
909+
trade name in a trademark sense to endorse or promote products or
910+
services of Licensee, or any third party.
911+
912+
8. By clicking on the "ACCEPT" button where indicated, or by copying,
913+
installing or otherwise using Python 1.6.1, Licensee agrees to be
914+
bound by the terms and conditions of this License Agreement.
915+
916+
ACCEPT
917+
918+
919+
CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2
920+
--------------------------------------------------
921+
922+
Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam,
923+
The Netherlands. All rights reserved.
924+
925+
Permission to use, copy, modify, and distribute this software and its
926+
documentation for any purpose and without fee is hereby granted,
927+
provided that the above copyright notice appear in all copies and that
928+
both that copyright notice and this permission notice appear in
929+
supporting documentation, and that the name of Stichting Mathematisch
930+
Centrum or CWI not be used in advertising or publicity pertaining to
931+
distribution of the software without specific, written prior
932+
permission.
933+
934+
STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
935+
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
936+
FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
937+
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
938+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
939+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
940+
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
941+
942+
ZERO-CLAUSE BSD LICENSE FOR CODE IN THE PYTHON DOCUMENTATION
943+
----------------------------------------------------------------------
944+
945+
Permission to use, copy, modify, and/or distribute this software for any
946+
purpose with or without fee is hereby granted.
947+
948+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
949+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
950+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
951+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
952+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
953+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
954+
PERFORMANCE OF THIS SOFTWARE.
955+
956+
----------------------------------------

examples/aggregators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Copyright (c) 2023, Oracle and/or its affiliates.
1+
# Copyright (c) 2023, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at
33
# https://oss.oracle.com/licenses/upl.
44

55
import asyncio
66
from dataclasses import dataclass
77
from decimal import Decimal
8-
from typing import List
8+
from typing import Dict, List
99

1010
from coherence import Aggregators, Filters, NamedMap, Session
1111

@@ -57,7 +57,7 @@ async def do_run() -> None:
5757
print("Average age of Hobbits under 40 :", int(avg_under_forty))
5858

5959
print("The oldest Hobbit for each hobby ...")
60-
results: dict[str, int] = await named_map.aggregate(Aggregators.group_by("hobbies", Aggregators.max("age")))
60+
results: Dict[str, int] = await named_map.aggregate(Aggregators.group_by("hobbies", Aggregators.max("age")))
6161
for hobby, age in results.items():
6262
print("Hobby: ", hobby, "Max age: ", age)
6363
finally:

pyproject.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022, Oracle and/or its affiliates.
1+
# Copyright (c) 2022, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at
33
# https://oss.oracle.com/licenses/upl.
44
[tool.poetry]
@@ -21,20 +21,21 @@ classifiers = [
2121
]
2222

2323
[tool.poetry.dependencies]
24-
python = "~3.11"
24+
python = "^3.8"
2525
protobuf = ">=4.23,<4.26"
2626
grpcio = ">=1.54,<1.63"
2727
grpcio-tools = ">=1.54,<1.63"
2828
jsonpickle = "~3.0"
2929
pymitter = ">=0.4,<0.6"
30+
typing-extensions = "~4.11"
3031

3132
[tool.poetry.dev-dependencies]
3233
pytest = "~8.1"
3334
pytest-asyncio = "~0.23"
3435
pytest-cov = "~5.0"
3536
pytest-unordered = "~0.6"
36-
pre-commit = "~3.7"
37-
Sphinx = "~7.2"
37+
pre-commit = "~3.5"
38+
Sphinx = "~7.1"
3839
sphinx-rtd-theme = "~2.0"
3940
sphinxcontrib-napoleon = "~0.7"
4041
m2r = "~0.3"

src/coherence/aggregator.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022, 2023, Oracle and/or its affiliates.
1+
# Copyright (c) 2022, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at
33
# https://oss.oracle.com/licenses/upl.
44

@@ -7,7 +7,9 @@
77
from abc import ABC
88
from decimal import Decimal
99
from enum import Enum, IntEnum
10-
from typing import Any, Dict, Generic, List, Optional, TypeAlias, TypeVar
10+
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
11+
12+
from typing_extensions import TypeAlias
1113

1214
from .comparator import Comparator, InverseComparator, SafeComparator
1315
from .extractor import ExtractorExpression, Extractors, ValueExtractor
@@ -21,7 +23,7 @@
2123
T = TypeVar("T")
2224
V = TypeVar("V")
2325

24-
ReducerResult: TypeAlias = Dict[K, Any | List[Any]]
26+
ReducerResult: TypeAlias = Dict[K, Union[Any, List[Any]]]
2527

2628

2729
class EntryAggregator(ABC, Generic[R]):
@@ -534,11 +536,10 @@ def __init__(self, query_type: RecordType):
534536

535537
@classmethod
536538
def get_type(cls, query_type: RecordType) -> dict[str, str]:
537-
match query_type:
538-
case RecordType.EXPLAIN:
539-
return {"enum": cls.EXPLAIN}
540-
case RecordType.TRACE:
541-
return {"enum": cls.TRACE}
539+
if query_type == RecordType.EXPLAIN:
540+
return {"enum": cls.EXPLAIN}
541+
elif query_type == RecordType.TRACE:
542+
return {"enum": cls.TRACE}
542543

543544

544545
@proxy("aggregator.ReducerAggregator")

0 commit comments

Comments
 (0)