Skip to content

Commit

Permalink
Support Python 3.11 (#2801)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilaner authored May 7, 2024
1 parent b362576 commit b1a48da
Show file tree
Hide file tree
Showing 33 changed files with 2,739 additions and 2,497 deletions.
4 changes: 4 additions & 0 deletions .changelog/2801.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changes:
- description: Added support for Python 3.11
type: feature
pr_number: 2801
41 changes: 22 additions & 19 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Python ${{ matrix.python-version }} - Setup Environment
uses: ./.github/actions/setup_environment
with:
python-version: "3.10"
python-version: "3.11"

- name: Validate Changelog
env:
Expand Down Expand Up @@ -53,23 +53,26 @@ jobs:
- name: Setup Python Environment
uses: ./.github/actions/setup_environment
with:
python-version: "3.10"
python-version: "3.11"

- name: Run Pre Commit
uses: pre-commit/[email protected]
- name: Cache pre-commit
uses: actions/cache@v4
with:
extra_args: --all-files
path: ~/.cache/pre-commit
key: pre-commit-3|3.11|${{ hashFiles('.pre-commit-config.yaml') }}|${{ hashFiles('.poetry.lock') }}

- name: Run pre-commit
run: poetry run pre-commit run --show-diff-on-failure --color=always --all-files

- name: Run Pytest collection
run: |
poetry run pytest --collect-only .
run: poetry run pytest --collect-only .

unit-tests:
name: Unit Tests / Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
fail-fast: false
defaults:
run:
Expand Down Expand Up @@ -114,7 +117,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
fail-fast: false
defaults:
run:
Expand Down Expand Up @@ -153,7 +156,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
fail-fast: false
defaults:
run:
Expand Down Expand Up @@ -193,10 +196,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.11"
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Run coverage
Expand Down Expand Up @@ -240,7 +243,7 @@ jobs:
- name: Python ${{ matrix.python-version }} - Setup Environment
uses: ./.github/actions/setup_environment
with:
python-version: "3.10"
python-version: "3.11"
working-dir: content
poetry-install-arguments: "--with ci"

Expand Down Expand Up @@ -362,7 +365,7 @@ jobs:
if: steps.files-changed.outputs.any_changed == 'true'
uses: ./.github/actions/setup_environment
with:
python-version: "3.10"
python-version: "3.11"

- name: Validate content master paths
if: steps.files-changed.outputs.any_changed == 'true'
Expand All @@ -381,7 +384,7 @@ jobs:
- name: Setup Python Environment
uses: ./.github/actions/setup_environment
with:
python-version: "3.10"
python-version: "3.11"

- name: Checkout content
uses: actions/checkout@v4
Expand Down Expand Up @@ -458,7 +461,7 @@ jobs:
- name: Setup Python Environment
uses: ./.github/actions/setup_environment
with:
python-version: "3.10"
python-version: "3.11"

- name: Checkout content
uses: actions/checkout@v4
Expand Down Expand Up @@ -515,7 +518,7 @@ jobs:
- name: Setup Python Environment
uses: ./.github/actions/setup_environment
with:
python-version: "3.10"
python-version: "3.11"

- name: Download artifacts
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -545,7 +548,7 @@ jobs:
if: steps.changed-files.outputs.any_changed == 'true'
uses: ./.github/actions/setup_environment
with:
python-version: "3.10"
python-version: "3.11"

- name: Generate Docs
if: steps.changed-files.outputs.any_changed == 'true'
Expand Down Expand Up @@ -574,7 +577,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.11"
cache: 'pip'

- name: pip intsall current project
Expand Down
168 changes: 1 addition & 167 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,173 +19,7 @@ repos:
hooks:
- id: mypy
exclude: tests/.*|demisto_sdk/commands/init/templates/.*
additional_dependencies:
- astroid==2.9.3 ; python_version >= "3.8" and python_version < "3.11"
- attrs==23.1.0 ; python_version >= "3.8" and python_version < "3.11"
- autopep8==1.7.0 ; python_version >= "3.8" and python_version < "3.11"
- backports-zoneinfo==0.2.1 ; python_version >= "3.8" and python_version < "3.9"
- bandit==1.7.5 ; python_version >= "3.8" and python_version < "3.11"
- bcrypt==4.0.1 ; python_version >= "3.8" and python_version < "3.11"
- beautifulsoup4==4.12.2 ; python_version >= "3.8" and python_version < "3.11"
- bracex==2.3.post1 ; python_version >= "3.8" and python_version < "3.11"
- cachetools==5.3.0 ; python_version >= "3.8" and python_version < "3.11"
- certifi==2023.7.22 ; python_version >= "3.8" and python_version < "3.11"
- cffi==1.15.1 ; python_version >= "3.8" and python_version < "3.11"
- cfgv==3.3.1 ; python_version >= "3.8" and python_version < "3.11"
- chardet==5.1.0 ; python_version >= "3.8" and python_version < "3.11"
- charset-normalizer==3.1.0 ; python_version >= "3.8" and python_version < "3.11"
- click==8.1.3 ; python_version >= "3.8" and python_version < "3.11"
- colorama==0.4.6 ; python_version >= "3.8" and python_version < "3.11"
- coloredlogs==15.0.1 ; python_version >= "3.8" and python_version < "3.11"
- commonmark==0.9.1 ; python_version >= "3.8" and python_version < "3.11"
- configparser==5.3.0 ; python_version >= "3.8" and python_version < "3.11"
- coverage==7.2.5 ; python_version >= "3.8" and python_version < "3.11"
- cryptography==36.0.2 ; python_version >= "3.8" and python_version < "3.11"
- dateparser==1.1.8 ; python_version >= "3.8" and python_version < "3.11"
- decorator==5.1.1 ; python_version >= "3.8" and python_version < "3.11"
- demisto-py==3.2.10 ; python_version >= "3.8" and python_version < "3.11"
- dictdiffer==0.9.0 ; python_version >= "3.8" and python_version < "3.11"
- dictor==0.1.11 ; python_version >= "3.8" and python_version < "3.11"
- distlib==0.3.6 ; python_version >= "3.8" and python_version < "3.11"
- docker==5.0.3 ; python_version >= "3.8" and python_version < "3.11"
- docopt==0.6.2 ; python_version >= "3.8" and python_version < "3.11"
- exceptiongroup==1.1.1 ; python_version >= "3.8" and python_version < "3.11"
- filelock==3.12.0 ; python_version >= "3.8" and python_version < "3.11"
- flatten-dict==0.4.2 ; python_version >= "3.8" and python_version < "3.11"
- freezegun==1.2.2 ; python_version >= "3.8" and python_version < "3.11"
- future==0.18.3 ; python_version >= "3.8" and python_version < "3.11"
- gitdb==4.0.10 ; python_version >= "3.8" and python_version < "3.11"
- gitpython==3.1.41 ; python_version >= "3.8" and python_version < "3.11"
- giturlparse==0.10.0 ; python_version >= "3.8" and python_version < "3.11"
- google-api-core==2.11.0 ; python_version >= "3.8" and python_version < "3.11"
- google-api-core[grpc]==2.11.0 ; python_version >= "3.8" and python_version < "3.11"
- google-auth==2.23.4 ; python_version >= "3.8" and python_version < "3.11"
- google-cloud-core==2.3.2 ; python_version >= "3.8" and python_version < "3.11"
- google-cloud-secret-manager==2.16.4 ; python_version >= "3.8" and python_version < "3.11"
- google-cloud-storage==2.13.0 ; python_version >= "3.8" and python_version < "3.11"
- google-crc32c==1.5.0 ; python_version >= "3.8" and python_version < "3.11"
- google-resumable-media==2.6.0 ; python_version >= "3.8" and python_version < "3.11"
- googleapis-common-protos==1.59.0 ; python_version >= "3.8" and python_version < "3.11"
- googleapis-common-protos[grpc]==1.59.0 ; python_version >= "3.8" and python_version < "3.11"
- grpc-google-iam-v1==0.12.7 ; python_version >= "3.8" and python_version < "3.11"
- grpcio-status==1.48.2 ; python_version >= "3.8" and python_version < "3.11"
- grpcio==1.59.2 ; python_version >= "3.8" and python_version < "3.11"
- humanfriendly==10.0 ; python_version >= "3.8" and python_version < "3.11"
- identify==2.5.24 ; python_version >= "3.8" and python_version < "3.11"
- idna==3.4 ; python_version >= "3.8" and python_version < "3.11"
- imagesize==1.4.1 ; python_version >= "3.8" and python_version < "3.11"
- importlib-resources==5.12.0 ; python_version >= "3.8" and python_version < "3.11"
- inflection==0.5.1 ; python_version >= "3.8" and python_version < "3.11"
- iniconfig==2.0.0 ; python_version >= "3.8" and python_version < "3.11"
- isort==5.12.0 ; python_version >= "3.8" and python_version < "3.11"
- joblib==1.2.0 ; python_version >= "3.8" and python_version < "3.11"
- json5==0.9.14 ; python_version >= "3.8" and python_version < "3.11"
- jsonschema==4.17.3 ; python_version >= "3.8" and python_version < "3.11"
- junitparser==3.1.0 ; python_version >= "3.8" and python_version < "3.11"
- lazy-object-proxy==1.9.0 ; python_version >= "3.8" and python_version < "3.11"
- lxml==5.1.0 ; python_version >= "3.8" and python_version < "3.11"
- mccabe==0.6.1 ; python_version >= "3.8" and python_version < "3.11"
- mergedeep==1.3.4 ; python_version >= "3.8" and python_version < "3.11"
- more-itertools==9.1.0 ; python_version >= "3.8" and python_version < "3.11"
- mypy-extensions==1.0.0 ; python_version >= "3.8" and python_version < "3.11"
- mypy==0.982 ; python_version >= "3.8" and python_version < "3.11"
- neo4j==5.14.1 ; python_version >= "3.8" and python_version < "3.11"
- networkx==2.8.8 ; python_version >= "3.8" and python_version < "3.11"
- nltk==3.8.1 ; python_version >= "3.8" and python_version < "3.11"
- nodeenv==1.7.0 ; python_version >= "3.8" and python_version < "3.11"
- ordered-set==4.1.0 ; python_version >= "3.8" and python_version < "3.11"
- orjson==3.8.11 ; python_version >= "3.8" and python_version < "3.11"
- packaging==23.1 ; python_version >= "3.8" and python_version < "3.11"
- paramiko==2.12.0 ; python_version >= "3.8" and python_version < "3.11"
- pbr==5.11.1 ; python_version >= "3.8" and python_version < "3.11"
- pebble==5.0.3 ; python_version >= "3.8" and python_version < "3.11"
- pkgutil-resolve-name==1.3.10 ; python_version >= "3.8" and python_version < "3.9"
- platformdirs==3.5.0 ; python_version >= "3.8" and python_version < "3.11"
- pluggy==1.0.0 ; python_version >= "3.8" and python_version < "3.11"
- pre-commit==3.5.0 ; python_version >= "3.8" and python_version < "3.11"
- prettytable==3.7.0 ; python_version >= "3.8" and python_version < "3.11"
- proto-plus==1.22.3 ; python_version >= "3.8" and python_version < "3.11"
- protobuf==3.19.6 ; python_version >= "3.8" and python_version < "3.11"
- pyasn1-modules==0.3.0 ; python_version >= "3.8" and python_version < "3.11"
- pyasn1==0.5.0 ; python_version >= "3.8" and python_version < "3.11"
- pycodestyle==2.10.0 ; python_version >= "3.8" and python_version < "3.11"
- pycparser==2.21 ; python_version >= "3.8" and python_version < "3.11"
- pydantic==1.10.7 ; python_version >= "3.8" and python_version < "3.11"
- pygments==2.15.1 ; python_version >= "3.8" and python_version < "3.11"
- pykwalify==1.8.0 ; python_version >= "3.8" and python_version < "3.11"
- pylint==2.12.2 ; python_version >= "3.8" and python_version < "3.11"
- pynacl==1.5.0 ; python_version >= "3.8" and python_version < "3.11"
- pypdf2==1.28.6 ; python_version >= "3.8" and python_version < "3.11"
- pyreadline3==3.4.1 ; sys_platform == "win32" and python_version >= "3.8" and python_version < "3.11"
- pyrsistent==0.19.3 ; python_version >= "3.8" and python_version < "3.11"
- pyspellchecker==0.6.3 ; python_version >= "3.8" and python_version < "3.11"
- pytest-freezegun==0.4.2 ; python_version >= "3.8" and python_version < "3.11"
- pytest==7.3.1 ; python_version >= "3.8" and python_version < "3.11"
- python-dateutil==2.8.2 ; python_version >= "3.8" and python_version < "3.11"
- python-dotenv==0.20.0 ; python_version >= "3.8" and python_version < "3.11"
- pytz-deprecation-shim==0.1.0.post0 ; python_version >= "3.8" and python_version < "3.11"
- pytz==2023.3 ; python_version >= "3.8" and python_version < "3.11"
- pywin32==227 ; python_version >= "3.8" and python_version < "3.11" and sys_platform == "win32"
- pyyaml==6.0 ; python_version >= "3.8" and python_version < "3.11"
- regex==2023.5.5 ; python_version >= "3.8" and python_version < "3.11"
- requests==2.29.0 ; python_version >= "3.8" and python_version < "3.11"
- rich==12.6.0 ; python_version >= "3.8" and python_version < "3.11"
- rsa==4.7.2 ; python_version >= "3.8" and python_version < "3.11"
- ruamel-yaml-clib==0.2.7 ; platform_python_implementation == "CPython" and python_version < "3.11" and python_version >= "3.8"
- ruamel-yaml==0.17.22 ; python_version >= "3.8" and python_version < "3.11"
- setuptools==67.7.2 ; python_version >= "3.8" and python_version < "3.11"
- shellingham==1.5.4 ; python_version >= "3.8" and python_version < "3.11"
- six==1.16.0 ; python_version >= "3.8" and python_version < "3.11"
- slack-sdk==3.21.3 ; python_version >= "3.8" and python_version < "3.11"
- smmap==5.0.0 ; python_version >= "3.8" and python_version < "3.11"
- soupsieve==2.4.1 ; python_version >= "3.8" and python_version < "3.11"
- stevedore==5.0.0 ; python_version >= "3.8" and python_version < "3.11"
- tabulate==0.9.0 ; python_version >= "3.8" and python_version < "3.11"
- tenacity==8.2.3 ; python_version >= "3.8" and python_version < "3.11"
- toml==0.10.2 ; python_version >= "3.8" and python_version < "3.11"
- tomli==2.0.1 ; python_version >= "3.8" and python_version < "3.11"
- tqdm==4.65.0 ; python_version >= "3.8" and python_version < "3.11"
- typed-ast==1.5.4 ; python_version >= "3.8" and python_version < "3.11"
- typer[all]==0.9.0 ; python_version >= "3.8" and python_version < "3.11"
- types-chardet==5.0.4.5 ; python_version >= "3.8" and python_version < "3.11"
- types-cryptography==3.3.23.2 ; python_version >= "3.8" and python_version < "3.11"
- types-dateparser==1.1.4.9 ; python_version >= "3.8" and python_version < "3.11"
- types-decorator==5.1.8.3 ; python_version >= "3.8" and python_version < "3.11"
- types-emoji==2.1.0.3 ; python_version >= "3.8" and python_version < "3.11"
- types-filelock==3.2.7 ; python_version >= "3.8" and python_version < "3.11"
- types-futures==3.3.8 ; python_version >= "3.8" and python_version < "3.11"
- types-ipaddress==1.0.8 ; python_version >= "3.8" and python_version < "3.11"
- types-markdown==3.4.2.8 ; python_version >= "3.8" and python_version < "3.11"
- types-mock==4.0.15.2 ; python_version >= "3.8" and python_version < "3.11"
- types-paramiko==2.12.0.1 ; python_version >= "3.8" and python_version < "3.11"
- types-pkg-resources==0.1.3 ; python_version >= "3.8" and python_version < "3.11"
- types-protobuf==4.24.0.4 ; python_version >= "3.8" and python_version < "3.11"
- types-pymysql==1.0.19.6 ; python_version >= "3.8" and python_version < "3.11"
- types-python-dateutil==2.8.19.12 ; python_version >= "3.8" and python_version < "3.11"
- types-pytz==2022.7.1.2 ; python_version >= "3.8" and python_version < "3.11"
- types-pyvmomi==8.0.0.1 ; python_version >= "3.8" and python_version < "3.11"
- types-pyyaml==6.0.12.9 ; python_version >= "3.8" and python_version < "3.11"
- types-requests==2.28.11 ; python_version >= "3.8" and python_version < "3.11"
- types-setuptools==67.7.0.1 ; python_version >= "3.8" and python_version < "3.11"
- types-six==1.16.21.8 ; python_version >= "3.8" and python_version < "3.11"
- types-tabulate==0.9.0.2 ; python_version >= "3.8" and python_version < "3.11"
- types-toml==0.10.8.7 ; python_version >= "3.8" and python_version < "3.11"
- types-ujson==5.7.0.5 ; python_version >= "3.8" and python_version < "3.11"
- types-urllib3==1.26.25.12 ; python_version >= "3.8" and python_version < "3.11"
- typing-extensions==4.5.0 ; python_version >= "3.8" and python_version < "3.11"
- tzdata==2023.3 ; python_version >= "3.8" and python_version < "3.11"
- tzlocal==4.3 ; python_version >= "3.8" and python_version < "3.11"
- ujson==5.7.0 ; python_version >= "3.8" and python_version < "3.11"
- urllib3==1.26.15 ; python_version >= "3.8" and python_version < "3.11"
- uv==0.1.24 ; python_version >= "3.8" and python_version < "3.11"
- virtualenv==20.23.0 ; python_version >= "3.8" and python_version < "3.11"
- vulture==2.7 ; python_version >= "3.8" and python_version < "3.11"
- wcmatch==8.4.1 ; python_version >= "3.8" and python_version < "3.11"
- wcwidth==0.2.6 ; python_version >= "3.8" and python_version < "3.11"
- websocket-client==1.5.1 ; python_version >= "3.8" and python_version < "3.11"
- wrapt==1.13.3 ; python_version >= "3.8" and python_version < "3.11"
- yamlordereddictloader==0.4.0 ; python_version >= "3.8" and python_version < "3.11"
- zipp==3.15.0 ; python_version >= "3.8" and python_version < "3.10"
language: system
- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from typing import Collection, Dict, List, Optional, Set, Tuple

import typer
from github import Github, WorkflowRun
from github import Github
from github.WorkflowRun import WorkflowRun
from slack_sdk import WebClient

from demisto_sdk.commands.common.logger import logger
Expand Down
7 changes: 4 additions & 3 deletions Utils/pytest_junit_parser.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
from enum import Enum
from functools import cached_property
from pathlib import Path
from typing import List, Optional

from junitparser import Failure, JUnitXml, Skipped, TestCase

from demisto_sdk.commands.common.StrEnum import StrEnum

class TestStatus(str, Enum):

class TestStatus(StrEnum):
PASSED = "PASSED"
FAILED = "FAILED"
SKIPPED = "SKIPPED"
UNKNOWN = "UNKNOWN"


class TestType(str, Enum):
class TestType(StrEnum):
UNIT_TESTS = "unit-tests"
INTEGRATION_TESTS = "integration-tests"
GRAPH_TESTS = "graph-tests"
Expand Down
36 changes: 36 additions & 0 deletions demisto_sdk/commands/common/StrEnum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""
Create a StrEnum class that works in both python <3.11 and >=3.11
https://tomwojcik.com/posts/2023-01-02/python-311-str-enum-breaking-change
"""

import sys

if sys.version_info >= (3, 11):
# StrEnum was added in 3.11
from enum import StrEnum as _StrEnum # type:ignore[attr-defined]
from typing import Self, overload

class StrEnum(_StrEnum):
"""
Since MyPy falsely detects usage of StrEnum as str, we patch it. See https://github.com/python/mypy/issues/14688.
"""

@overload
def __new__(cls, object: object = ...) -> Self:
...

@overload
def __new__(
cls, object: object, encoding: str = ..., errors: str = ...
) -> Self:
...

def __new__(cls, *values):
return _StrEnum._new_member_(cls, *values)

else:
from enum import Enum

class StrEnum(str, Enum): # type:ignore[no-redef]
def __str__(self):
return self
Loading

0 comments on commit b1a48da

Please sign in to comment.