diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index dc6350a8..57b398e0 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -16,6 +16,7 @@ branchProtectionRules: - 'unit (3.9)' - 'unit (3.10, cpp)' - 'unit (3.10)' + - 'unit (3.11)' - cover - OwlBot Post Processor - 'cla/google' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 219bb5a3..1e8f9636 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,20 +30,23 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up Python 3.8 + - name: Set up Python 3.9 uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.9" - name: Install nox. run: python -m pip install nox - name: Build the documentation. run: nox -s docs unit: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: - python: ['3.6', '3.7', '3.8', '3.9', '3.10'] + python: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11'] variant: ['', 'cpp', 'upb'] + exclude: + - variant: "cpp" + python: 3.11 steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python }} @@ -53,16 +56,22 @@ jobs: - name: Install nox run: | pip install nox + # Trim the Python version string + - name: Trim python version + run: | + PYTHON_VERSION_TRIMMED=${{ matrix.python }} + PYTHON_VERSION_TRIMMED=$(echo $PYTHON_VERSION_TRIMMED | cut -c1-4) + echo "PYTHON_VERSION_TRIMMED=$PYTHON_VERSION_TRIMMED" >> $GITHUB_ENV - name: Run unit tests env: - COVERAGE_FILE: .coverage-${{ matrix.variant }}-${{ matrix.python }} + COVERAGE_FILE: .coverage-${{ matrix.variant }}-${{ env.PYTHON_VERSION_TRIMMED }} run: | - nox -s unit${{ matrix.variant }}-${{ matrix.python }} + nox -s unit${{ matrix.variant }}-${{ env.PYTHON_VERSION_TRIMMED }} - name: Upload coverage results uses: actions/upload-artifact@v3 with: name: coverage-artifacts - path: .coverage-${{ matrix.variant }}-${{ matrix.python }} + path: .coverage-${{ matrix.variant }}-${{ env.PYTHON_VERSION_TRIMMED }} cover: runs-on: ubuntu-latest needs: diff --git a/docs/conf.py b/docs/conf.py index 4c77371e..aeaf3bed 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -64,7 +64,7 @@ # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = "en" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. diff --git a/noxfile.py b/noxfile.py index 576a616c..e271fa87 100644 --- a/noxfile.py +++ b/noxfile.py @@ -28,8 +28,12 @@ "3.8", "3.9", "3.10", + "3.11", ] +# Error if a python version is missing +nox.options.error_on_missing_interpreters = True + @nox.session(python=PYTHON_VERSIONS) def unit(session, proto="python"): @@ -64,7 +68,7 @@ def unit(session, proto="python"): # Check if protobuf has released wheels for new python versions # https://pypi.org/project/protobuf/#files # This list will generally be shorter than 'unit' -@nox.session(python=PYTHON_VERSIONS) +@nox.session(python=["3.6", "3.7", "3.8", "3.9", "3.10"]) def unitcpp(session): return unit(session, proto="cpp") @@ -74,8 +78,7 @@ def unitupb(session): return unit(session, proto="upb") -# Just use the most recent version for docs -@nox.session(python=PYTHON_VERSIONS[-1]) +@nox.session(python="3.9") def docs(session): """Build the docs.""" diff --git a/proto/enums.py b/proto/enums.py index 6f13d32e..6207ad7d 100644 --- a/proto/enums.py +++ b/proto/enums.py @@ -58,8 +58,11 @@ def __new__(mcls, name, bases, attrs): # In 3.7 onwards, we can define an _ignore_ attribute and do some # mucking around with that. if pb_options in attrs._member_names: - idx = attrs._member_names.index(pb_options) - attrs._member_names.pop(idx) + if isinstance(attrs._member_names, list): + idx = attrs._member_names.index(pb_options) + attrs._member_names.pop(idx) + else: # Python 3.11.0b3 + del attrs._member_names[pb_options] # Make the descriptor. enum_desc = descriptor_pb2.EnumDescriptorProto( diff --git a/setup.py b/setup.py index a1d51f7d..ef2de312 100644 --- a/setup.py +++ b/setup.py @@ -55,6 +55,7 @@ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Topic :: Software Development :: Code Generators", "Topic :: Software Development :: Libraries :: Python Modules", ], diff --git a/tests/test_enum_total_ordering.py b/tests/test_enum_total_ordering.py index ad7a3691..584a1831 100644 --- a/tests/test_enum_total_ordering.py +++ b/tests/test_enum_total_ordering.py @@ -49,7 +49,11 @@ def test_total_ordering_w_other_enum_type(): for item in enums_test.OtherEnum: assert not to_compare == item - assert to_compare.SOME_VALUE != item + assert type(to_compare).SOME_VALUE != item + try: + assert to_compare.SOME_VALUE != item + except AttributeError: # Python 3.11.0b3 + pass with pytest.raises(TypeError): assert not to_compare < item with pytest.raises(TypeError):