Skip to content

Commit ecffafa

Browse files
authored
🐛Python 3.11 support (#80)
<!-- Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors. All rights reserved. SPDX-License-Identifier: Apache-2.0 --> ### Description <!-- Please add any detail or context that would be useful to a reviewer. --> Make updates to allow the codebase to run on python 3.11 ### Test Coverage <!-- Please put an `x` in the correct box e.g. `[x]` to indicate the testing coverage of this change. --> - [x] This change is covered by existing or additional automated tests. - [ ] Manual testing has been performed (and evidence provided) as automated testing was not feasible. - [ ] Additional tests are not required for this change (e.g. documentation update).
1 parent 2fe5dec commit ecffafa

20 files changed

+76
-36
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ env:
1111
python_cache_windows_path: ~\AppData\Local\pip\Cache
1212
python_cache_ubuntu_path: ~/.cache/pip
1313
pipenv_version: 2022.11.25
14-
python_version: '3.10'
14+
python_version: '3.11'
1515

1616
jobs:
1717
# Check that a news file has been added to this branch when a PR is created
@@ -166,7 +166,7 @@ jobs:
166166
fail-fast: false
167167
matrix:
168168
os: [ubuntu-latest ] # FIXME add other platforms when much quicker macOS-latest, windows-latest]
169-
python-version: ["3.8", "3.9", "3.10"]
169+
python-version: ["3.8", "3.9", "3.10", "3.11"]
170170
multi-platform:
171171
- ${{ github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' }}
172172
# include:
@@ -180,7 +180,7 @@ jobs:
180180
include:
181181
- os: macOS-latest
182182
multi-platform: false
183-
python-version: 3.9
183+
python-version: 3.11
184184
# - os: windows-latest
185185
# multi-platform: false
186186
# python-version: 3.9

.github/workflows/mypy.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: "Run type checker"
2+
on:
3+
push:
4+
branches: [ "main" ]
5+
pull_request:
6+
# The branches below must be a subset of the branches above
7+
branches: [ "main" ]
8+
9+
jobs:
10+
type-check:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Setup Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: "3.11"
19+
- name: Install pipenv
20+
shell: bash
21+
run: |
22+
python -m pip install --upgrade pipenv
23+
pipenv install --dev
24+
- name: Type check with mypy
25+
run: |
26+
pipenv run mypy ./continuous_delivery_scripts

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: GitHub Release
22

33
env:
44
pipenv_version: 2022.11.25
5-
python_version: '3.10'
5+
python_version: '3.11'
66

77
on:
88
workflow_dispatch:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Pipfile.lock
66

77
# macOS
88
.DS_Store
9+
.tool-versions
910

1011
# Python
1112
*.pyc

DEVELOPMENT.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ Setup Pipenv to use Python 3 (Python 2 is not supported) and install package dev
5151

5252
```bash
5353
cd continuous-delivery-scripts/
54-
pipenv --three
5554
pipenv install --dev
5655
```
5756

Pipfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ allow_prereleases = false
2323

2424
[packages]
2525
continuous-delivery-scripts = {editable = true, path = "."}
26+
types-toml = "*"
27+
types-setuptools = "*"

continuous_delivery_scripts/assert_news.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pathlib
99
import re
1010
import sys
11-
from typing import List, Union
11+
from typing import Union, Optional, Iterable, Any, List
1212

1313
from continuous_delivery_scripts.utils.configuration import configuration, ConfigurationVariable
1414
from continuous_delivery_scripts.utils.git_helpers import ProjectTempClone, LocalProjectRepository, GitWrapper
@@ -98,6 +98,12 @@ def validate_news_files(git: GitWrapper, root_dir: str, news_dir: str) -> None:
9898
validate_news_file(absolute_file_path)
9999

100100

101+
def _convert_to_string_iter(list: Optional[List[Any]]) -> Iterable[str]:
102+
if list is None:
103+
return []
104+
return [str(item) for item in list]
105+
106+
101107
def generate_news_file(git: GitWrapper, news_dir: pathlib.Path) -> pathlib.Path:
102108
"""Adds a news file if the branch corresponds to an dependency update.
103109
@@ -114,8 +120,9 @@ def generate_news_file(git: GitWrapper, news_dir: pathlib.Path) -> pathlib.Path:
114120
if not configuration.get_value(ConfigurationVariable.AUTOGENERATE_NEWS_FILE_ON_DEPENDENCY_UPDATE):
115121
raise EnvironmentError(f"Branch {current_branch} must contain a news file.")
116122

123+
list_groups = _convert_to_string_iter(groups)
117124
message = str(configuration.get_value(ConfigurationVariable.DEPENDENCY_UPDATE_NEWS_MESSAGE)).format(
118-
message=", ".join(groups)
125+
message=", ".join(list_groups)
119126
)
120127
logger.info(f"Generating a news file with content: {message}...")
121128
return create_news_file(
@@ -130,7 +137,7 @@ def _commit_news_file(git: GitWrapper, news_file: pathlib.Path, local: bool) ->
130137
logger.info(f"Committing news file {str(news_file)}...")
131138
if not local:
132139
git.configure_for_github()
133-
git.add(str(news_file))
140+
git.add(news_file)
134141
git.commit("📰 Automatic changes ⚙ Adding news file")
135142
if not local:
136143
git.push()

continuous_delivery_scripts/get_version.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""Determine the project new version."""
66
import sys
77

8+
from typing import Optional
89
import argparse
910
import logging
1011
from continuous_delivery_scripts.utils.versioning import calculate_version, determine_version_string
@@ -15,7 +16,7 @@
1516
logger = logging.getLogger(__name__)
1617

1718

18-
def get_project_version_string(commit_type: CommitType) -> str:
19+
def get_project_version_string(commit_type: CommitType) -> Optional[str]:
1920
"""Determine the project version string.
2021
2122
Args:

continuous_delivery_scripts/language_specifics.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
logger = logging.getLogger(__name__)
1717

1818

19-
def _retrieve_all_subclasses(subclass: Type[BaseLanguage]) -> Set[Type[BaseLanguage]]:
20-
subclasses = set()
19+
def _retrieve_all_subclasses(subclass: Type) -> Set[Type]:
20+
subclasses: set = set()
2121
if not subclass:
2222
return subclasses
2323
if subclass != BaseLanguage:
@@ -31,10 +31,10 @@ def all_language_plugins() -> Dict[str, BaseLanguage]:
3131
"""Fetches all language plugins which inherit from BaseLanguage.
3232
3333
Returns:
34-
A list of classes containing language plugins
34+
A list of classes containing language plugins
3535
"""
3636
all_plugins = _retrieve_all_subclasses(BaseLanguage)
37-
return {la.get_related_language().lower().strip(): la for la in [lang() for lang in all_plugins]} # type: ignore
37+
return {la.get_related_language().lower().strip(): la for la in [lang() for lang in all_plugins]}
3838

3939

4040
def fetch_project_language_plugin(all_plugins: Dict[str, BaseLanguage], language: str) -> BaseLanguage:
@@ -45,7 +45,7 @@ def fetch_project_language_plugin(all_plugins: Dict[str, BaseLanguage], language
4545
language: the language to select
4646
4747
Returns:
48-
A language plugin corresponding to the language requested
48+
A language plugin corresponding to the language requested
4949
"""
5050
return cast(BaseLanguage, all_plugins.get(_sanitise_program_language(language)))
5151

continuous_delivery_scripts/plugins/ci.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def get_related_language(self) -> str:
3030
"""Gets the related language."""
3131
return get_language_from_file_name(__file__)
3232

33-
def get_version_tag(self, version: str):
33+
def get_version_tag(self, version: str) -> str:
3434
"""Gets tag based on version."""
3535
cleansed_version = version.strip().lstrip("v")
3636
return f"v{cleansed_version}"

0 commit comments

Comments
 (0)