Skip to content

Commit 41fc805

Browse files
committed
🚨 fix: codeql warning
1 parent ca35c33 commit 41fc805

File tree

3 files changed

+26
-33
lines changed

3 files changed

+26
-33
lines changed

.github/workflows/pull-request.yml

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-22.04
1414
steps:
1515
- uses: actions/checkout@v5
16-
- uses: pre-commit/action@v3.0.0
16+
- uses: pre-commit/action@v3.0.1
1717
- name: setup fuse
1818
run: |
1919
sudo apt-get update --fix-missing
@@ -28,7 +28,7 @@ jobs:
2828
cd pkg && make ./configure --py3_ver=11 --arch_old=2014 && make osc-cli-x86_64.AppImage
2929
./osc-cli-x86_64.AppImage 2>&1 | grep Usage
3030
- name: Upload artifacts
31-
uses: actions/upload-artifact@v2
31+
uses: actions/upload-artifact@v5
3232
with:
3333
name: osc-cli
3434
path: |
@@ -43,7 +43,7 @@ jobs:
4343
runs-on: ubuntu-latest
4444
steps:
4545
- uses: actions/checkout@v5
46-
- uses: pre-commit/action@v2.0.3
46+
- uses: pre-commit/action@v3.0.1
4747
- name: Set up Python
4848
uses: actions/setup-python@v2
4949
with:
@@ -75,18 +75,3 @@ jobs:
7575
OSC_TEST_REGION: ${{ secrets.OSC_TEST_REGION }}
7676
- name: Test python package building
7777
run: make build
78-
dependabot-auto-merge:
79-
needs: [tests-packaging, tests-app]
80-
runs-on: ubuntu-latest
81-
if: ${{ github.actor == 'dependabot[bot]' }}
82-
steps:
83-
- name: Dependabot metadata
84-
id: metadata
85-
uses: dependabot/fetch-metadata@v1.1.1
86-
with:
87-
github-token: "${{ secrets.GITHUB_TOKEN }}"
88-
- name: Auto-merge
89-
run: gh pr merge --auto --rebase "$PR_URL"
90-
env:
91-
PR_URL: ${{github.event.pull_request.html_url}}
92-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

osc_sdk/sdk.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import fire
1717
import requests
1818
import xmltodict
19-
from requests.models import Request, Response
19+
from requests.models import Response
2020
from typing_extensions import TypedDict
2121

2222
CANONICAL_URI = "/"
@@ -141,8 +141,8 @@ def __str__(self) -> str:
141141
return (
142142
f"Error --> status = {self.status_code}, "
143143
f"code = {self.error_code}, "
144-
f'{"code_type = " if self.code_type is not None else ""}'
145-
f'{self.code_type + ", " if self.code_type is not None else ""}'
144+
f"{'code_type = ' if self.code_type is not None else ''}"
145+
f"{self.code_type + ', ' if self.code_type is not None else ''}"
146146
f"Reason = {self.message}, "
147147
f"request_id = {self.request_id}"
148148
)
@@ -389,7 +389,7 @@ def make_request(self, call: str, **kwargs: CallParameters):
389389
"content-type": self.CONTENT_TYPE,
390390
"host": self.host,
391391
"x-amz-date": self.date,
392-
"x-amz-target": f'{self.API_NAME}_{datetime.date.today().strftime("%Y%m%d")}.{call}',
392+
"x-amz-target": f"{self.API_NAME}_{datetime.date.today().strftime('%Y%m%d')}.{call}",
393393
}
394394

395395
payload_hash = hashlib.sha256(
@@ -521,7 +521,7 @@ def build_headers(self, target: str, json_parameters: str) -> Headers:
521521

522522
signed_headers = "host;x-amz-date;x-amz-target"
523523
canonical_headers = (
524-
f"host:{self.host}\n" f"x-amz-date:{self.date}\n" f"x-amz-target:{target}\n"
524+
f"host:{self.host}\nx-amz-date:{self.date}\nx-amz-target:{target}\n"
525525
)
526526
headers = {
527527
"content-type": self.CONTENT_TYPE,
@@ -607,7 +607,7 @@ def get_parameters(
607607
# Specific to ICU
608608
if (
609609
self.authentication_method == "accesskey"
610-
or self.authentication_method == None
610+
or self.authentication_method is None
611611
):
612612
data.update({"AuthenticationMethod": "accesskey"})
613613

@@ -702,7 +702,7 @@ def build_headers(self, target: str, _) -> Headers:
702702

703703
signed_headers = "host;x-osc-date;x-osc-target"
704704
canonical_headers = (
705-
f"host:{self.host}\n" f"x-osc-date:{self.date}\n" f"x-osc-target:{target}\n"
705+
f"host:{self.host}\nx-osc-date:{self.date}\nx-osc-target:{target}\n"
706706
)
707707
headers = {
708708
"Content-Type": self.CONTENT_TYPE,
@@ -733,15 +733,14 @@ def get_conf(profile: str) -> Configuration:
733733
for v in json_profiles:
734734
json_profile = json_profiles[v]
735735
if "region" in json_profile:
736-
737736
# use default stuffs only when "region" is use
738737
# to keep region_name format retrocompatible
739-
if not "host" in json_profile and not "endpoint" in json_profile:
738+
if "host" not in json_profile and "endpoint" not in json_profile:
740739
json_profile["host"] = DEFAULT_HOST
741-
if not "https" in json_profile:
740+
if "https" not in json_profile:
742741
json_profile["https"] = True
743742

744-
if not "region_name" in json_profile:
743+
if "region_name" not in json_profile:
745744
json_profile["region_name"] = json_profile["region"]
746745
del json_profile["region"]
747746
conf = cast(Mapping[str, Configuration], json_profiles)
@@ -768,7 +767,6 @@ def api_connect(
768767
config_path: Optional[str] = None,
769768
**kwargs: CallParameters,
770769
):
771-
772770
calls = {
773771
"api": OSCCall,
774772
"directlink": DirectLinkCall,
@@ -811,8 +809,8 @@ def main():
811809
global PASSWORD_ARG
812810
PASSWORD_ARG = argv[i + 1]
813811
elif a == "--bash_completion":
814-
f = open(BASH_COMPLETION_PATH, "r")
815-
print(f.read())
812+
with open(BASH_COMPLETION_PATH, "r") as f:
813+
print(f.read())
816814
sys.exit()
817815
return 0
818816
elif a == "--version":

setup.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
from setuptools import find_packages, setup
2+
import os
3+
4+
5+
def get_long_description():
6+
root_path = os.path.dirname(os.path.abspath(__file__))
7+
with open(os.path.join(root_path, "README.md"), "r", encoding="utf-8") as fd:
8+
return fd.read()
9+
210

311
setup(
412
name="osc-sdk",
@@ -7,7 +15,7 @@
715
author="Outscale SAS",
816
author_email="contact@outscale.com",
917
description="Outscale API SDK and CLI",
10-
long_description=open("README.md").read(),
18+
long_description=get_long_description(),
1119
long_description_content_type="text/markdown",
1220
include_package_data=True,
1321
license="BSD",
@@ -20,6 +28,8 @@
2028
"Programming Language :: Python :: 3.8",
2129
"Programming Language :: Python :: 3.9",
2230
"Programming Language :: Python :: 3.10",
31+
"Programming Language :: Python :: 3.11",
32+
"Programming Language :: Python :: 3.12",
2333
"Operating System :: OS Independent",
2434
],
2535
url="https://github.com/outscale/osc-cli",

0 commit comments

Comments
 (0)