Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/autoupdate-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Autoupdate PR
on:
push:
branches:
- combined-sdk

jobs:
update_pull_requests:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.DISPATCH_ACCESS_TOKEN }}

- name: Set up Git
run: |
git config --global user.name 'box-sdk-build'
git config --global user.email 'box-sdk-build@box.com'

- name: Fetch all branches and tags
run: git fetch --prune --unshallow

- name: Auto update pull requests
run: |
PR_LIST=$(curl -s -H "Authorization: Bearer ${{ secrets.DISPATCH_ACCESS_TOKEN }}" "https://api.github.com/repos/$GITHUB_REPOSITORY/pulls?state=open" | jq -r '.[] | .head.ref')
for pr_branch in $PR_LIST; do
git checkout "$pr_branch"
if git merge origin/combined-sdk; then
git push
else
# Conflict occurred, resolve by keeping our changes
git checkout --ours .
git add .
git commit -m "Auto resolve conflict by keeping our changes"
git push
fi
done
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Build
name: Build boxsdk
on:
pull_request:
branches:
- main
- combined-sdk
push:
branches:
- main
- combined-sdk

jobs:
build:
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/create_release.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Format Check

on:
pull_request:
branches:
- combined-sdk

jobs:
black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.8"

- name: Install Tox
run: pip install tox

- name: Run Format Check
run: |
tox -e format-check || (echo "Format check failed! Please run 'tox -e format' locally and fix formatting." && exit 1)
59 changes: 59 additions & 0 deletions .github/workflows/integration-tests-gen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Integration tests box_sdk_gen
on:
pull_request:
branches:
- combined-sdk
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
python-version:
- '3.8'
- '3.11'
- '3.13'
name: Build with Python ${{ matrix.python-version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e .[dev]
python -m pip install tox-gh-actions
- name: All Tests
if: startsWith(github.head_ref, 'codegen-release')
env:
JWT_CONFIG_BASE_64: ${{ secrets.JWT_CONFIG_BASE_64 }}
ADMIN_USER_ID: ${{ secrets.ADMIN_USER_ID }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
USER_ID: ${{ secrets.USER_ID }}
ENTERPRISE_ID: ${{ secrets.ENTERPRISE_ID }}
BOX_FILE_REQUEST_ID: ${{ secrets.BOX_FILE_REQUEST_ID }}
BOX_EXTERNAL_USER_EMAIL: ${{ secrets.BOX_EXTERNAL_USER_EMAIL }}
BOX_EXTERNAL_USER_ID: ${{ secrets.BOX_EXTERNAL_USER_ID }}
APP_ITEM_ASSOCIATION_FILE_ID: ${{ secrets.APP_ITEM_ASSOCIATION_FILE_ID }}
APP_ITEM_ASSOCIATION_FOLDER_ID: ${{ secrets.APP_ITEM_ASSOCIATION_FOLDER_ID }}
WORKFLOW_FOLDER_ID: ${{ secrets.WORKFLOW_FOLDER_ID }}
APP_ITEM_SHARED_LINK: ${{ secrets.APP_ITEM_SHARED_LINK }}
SLACK_AUTOMATION_USER_ID: ${{ secrets.SLACK_AUTOMATION_USER_ID }}
SLACK_ORG_ID: ${{ secrets.SLACK_ORG_ID }}
SLACK_PARTNER_ITEM_ID: ${{ secrets.SLACK_PARTNER_ITEM_ID }}
run: |
tox -e integration-tests-gen
- name: Smoke Tests
if: "!startsWith(github.head_ref, 'codegen-release')"
env:
JWT_CONFIG_BASE_64: ${{ secrets.JWT_CONFIG_BASE_64 }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
USER_ID: ${{ secrets.USER_ID }}
ENTERPRISE_ID: ${{ secrets.ENTERPRISE_ID }}
run: |
tox -e smoke-tests-gen
18 changes: 12 additions & 6 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
name: Integration tests
name: Integration tests boxsdk
on:
pull_request:
branches:
- main
push:
branches:
- main
- combined-sdk

jobs:
tests:
Expand All @@ -27,10 +24,19 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"
- name: Run integration tests
- name: All Tests
if: startsWith(github.head_ref, 'codegen-release')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JWT_CONFIG_BASE_64: ${{ secrets.JWT_CONFIG_BASE_64 }}
ADMIN_USER_ID: ${{ secrets.ADMIN_USER_ID }}
run: |
tox -e integration-tests
- name: Smoke Tests
if: "!startsWith(github.head_ref, 'codegen-release')"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JWT_CONFIG_BASE_64: ${{ secrets.JWT_CONFIG_BASE_64 }}
ADMIN_USER_ID: ${{ secrets.ADMIN_USER_ID }}
run: |
tox -e smoke-tests
28 changes: 0 additions & 28 deletions .github/workflows/releases.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/semantic-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
- opened
- edited
- synchronize
branches:
- combined-sdk

jobs:
main:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spell-check-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
pull_request_target:
types: [opened, synchronize, edited]
branches:
- main
- combined-sdk
jobs:
spellcheck-request-title:
runs-on: ubuntu-latest
Expand Down
13 changes: 2 additions & 11 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@

# C0111 => Missing docstring
# W0108 => unnecessary lambda
# W0142 => Used * or ** magic
# R0401 => cyclic-import
disable=I, C0111, W0108, W0142, R0921, R0922, W0232, R0401, R0801
disable=I, C0111, W0108, R0401, R0801


[REPORTS]
Expand All @@ -50,11 +49,6 @@ disable=I, C0111, W0108, W0142, R0921, R0922, W0232, R0401, R0801
# mypackage.mymodule.MyReporterClass.
output-format=text

# Put messages in a separate file for each module / package specified on the
# command line instead of printing them on stdout. Reports (if any) will be
# written in a file name "pylint_global.[txt|html]".
files-output=no

# Tells whether to display a full report or only the messages
reports=no

Expand All @@ -72,9 +66,6 @@ msg-template={module}:{line}:{column}: [{msg_id}({symbol}), {obj}] {msg}

[BASIC]

# List of builtins function names that should not be used, separated by a comma
bad-functions=map,filter,apply,input

# Regular expression which should only match correct module names
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$

Expand Down Expand Up @@ -260,4 +251,4 @@ int-import-graph=

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception
overgeneral-exceptions=builtins.Exception
20 changes: 10 additions & 10 deletions boxsdk/auth/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,20 +331,20 @@ def _oauth_exception(
Create a BoxOAuthException instance to raise. If the error response is JSON, parse it and include the
code and message in the exception.
"""
exception_kwargs = dict(
status=network_response.status_code,
url=url,
method='POST',
network_response=network_response,
)
exception_kwargs = {
'status': network_response.status_code,
'url': url,
'method': 'POST',
'network_response': network_response,
}
if is_json_response(network_response):
json_response = network_response.json()
exception_kwargs.update(
dict(
code=json_response.get('code') or json_response.get('error'),
message=json_response.get('message')
{
'code': json_response.get('code') or json_response.get('error'),
'message': json_response.get('message')
or json_response.get('error_description'),
)
}
)
else:
exception_kwargs['message'] = network_response.content
Expand Down
5 changes: 0 additions & 5 deletions boxsdk/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ def __init__(self, oauth: 'OAuth2', session: Session = None):
The session object to use. If None is provided then an instance of :class:`AuthorizedSession` will be used.
"""
super().__init__()
warn(
'Package \'boxsdk\' is going to be deprecated soon. Please use \'box-sdk-gen\' instead.',
DeprecationWarning,
)
self._oauth = oauth
if session is not None:
self._session = session
Expand Down Expand Up @@ -1336,7 +1332,6 @@ def get_url(self, endpoint: str, *args: Any) -> str:
:param args:
Additional parts of the endpoint URL.
"""
# pylint:disable=no-self-use
return self._session.get_url(endpoint, *args)

def device_pinner(self, device_pin_id: str) -> 'DevicePinner':
Expand Down
13 changes: 6 additions & 7 deletions boxsdk/object/base_api_json_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ def __init__(cls, name, bases, attrs):
super().__init__(name, bases, attrs)
item_type = attrs.get('_item_type', None)
if item_type is not None:
Translator._default_translator.register(
item_type, cls
) # pylint:disable=protected-access,no-member
# pylint:disable=protected-access,no-member
Translator._default_translator.register(item_type, cls)
# Some types have - in them instead of _ in the API.
if "-" in item_type:
# pylint:disable=protected-access,no-member
Translator._default_translator.register(
item_type.replace("-", "_"), cls
) # pylint:disable=protected-access,no-member
)


class BaseAPIJSONObject(metaclass=BaseAPIJSONObjectMeta):
Expand Down Expand Up @@ -144,9 +144,8 @@ def _untranslate(cls, value: Any) -> Iterable:
A dictionary containing the untranslated object.
"""
if isinstance(value, BaseAPIJSONObject):
return cls._untranslate(
value._response_object
) # pylint:disable=protected-access
# pylint:disable=protected-access
return cls._untranslate(value._response_object)
if isinstance(value, dict):
return {k: cls._untranslate(v) for (k, v) in value.items()}
if isinstance(value, list):
Expand Down
6 changes: 4 additions & 2 deletions boxsdk/object/upload_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ def upload_part_bytes(
part_content_sha1 = sha1.digest()

range_end = min(
offset + self.part_size - 1, total_size - 1
) # pylint:disable=no-member
# pylint:disable=no-member
offset + self.part_size - 1,
total_size - 1,
)
headers = {
'Content-Type': 'application/octet-stream',
'Digest': f'SHA={base64.b64encode(part_content_sha1).decode("utf-8")}',
Expand Down
Loading