Skip to content

Commit 3142621

Browse files
authored
Merge pull request #996 from kellerza/master
Migrate package to uv
2 parents 8268769 + f1a5899 commit 3142621

File tree

84 files changed

+2010
-304
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+2010
-304
lines changed

.github/dependabot.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
groups:
8+
actions-deps:
9+
patterns:
10+
- "*"
11+
12+
# - package-ecosystem: "uv"
13+
# directory: "/"
14+
# schedule:
15+
# interval: "daily"
16+
# groups:
17+
# dev-deps:
18+
# dependency-type: "development"

.github/workflows/python-app.yml

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88

99
env:
1010
DEFAULT_PYTHON: "3.10"
11+
RUFF_VERSION: 0.14.10
12+
UV_VERSION: 0.9.22
1113

1214
permissions:
1315
contents: read
@@ -16,13 +18,21 @@ jobs:
1618
ruff:
1719
runs-on: ubuntu-latest
1820
steps:
19-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v6
2022
- uses: chartboost/ruff-action@v1
23+
with:
24+
args: "check --fix"
25+
version: ${{ env.RUFF_VERSION }}
26+
# A proposal to replace black & pylint
27+
# - uses: chartboost/ruff-action@v1
28+
# with:
29+
# args: "format --check"
30+
# version: ${{ env.RUFF_VERSION }}
2131

2232
black:
2333
runs-on: ubuntu-latest
2434
steps:
25-
- uses: actions/checkout@v3
35+
- uses: actions/checkout@v6
2636
- uses: actions/setup-python@v3
2737
with:
2838
python-version: ${{ env.DEFAULT_PYTHON }}
@@ -31,18 +41,19 @@ jobs:
3141
pylint:
3242
runs-on: ubuntu-latest
3343
steps:
34-
- uses: actions/checkout@v3
44+
- uses: actions/checkout@v6
3545
- uses: actions/setup-python@v4
3646
with:
3747
python-version: ${{ env.DEFAULT_PYTHON }}
38-
- name: Install dependencies
39-
run: |
40-
python -m pip install --upgrade pip
41-
pip install -r requirements.txt
42-
pip install -r requirements-dev.txt
48+
- name: Install uv
49+
uses: astral-sh/setup-uv@v7
50+
with:
51+
version: ${{ env.UV_VERSION }}
52+
- name: Install Requirements
53+
run: uv sync --frozen --all-extras
4354
- name: Run Pylint
4455
run: |
45-
pylint --disable=too-many-positional-arguments office365
56+
uv run pylint office365
4657
4758
pytest:
4859
runs-on: ubuntu-latest
@@ -51,16 +62,17 @@ jobs:
5162
- black
5263
- pylint
5364
steps:
54-
- uses: actions/checkout@v3
65+
- uses: actions/checkout@v6
5566
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
56-
uses: actions/setup-python@v3
67+
uses: actions/setup-python@v6
5768
with:
5869
python-version: ${{ env.DEFAULT_PYTHON }}
59-
- name: Install dependencies
60-
run: |
61-
python -m pip install --upgrade pip
62-
pip install -r requirements.txt
63-
pip install -r requirements-dev.txt
70+
- name: Install uv
71+
uses: astral-sh/setup-uv@v7
72+
with:
73+
version: ${{ env.UV_VERSION }}
74+
- name: Install Requirements
75+
run: uv sync --frozen --all-extras
6476
- name: Test with pytest (skip entirely if secrets missing)
6577
env:
6678
office365_python_sdk_securevars: ${{ secrets.OFFICE365_PYTHON_SDK_SECUREVARS }}
@@ -69,5 +81,5 @@ jobs:
6981
echo "No secrets available; skipping pytest"; \
7082
exit 0; \
7183
else \
72-
pytest; \
84+
uv run pytest; \
7385
fi

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ venv.bak/
1616
# C extensions
1717
*.so
1818

19+
# Caches
20+
.mypy_cache
21+
.ruff_cache
22+
1923
# Distribution / packaging
2024
.Python
2125
build/

.pre-commit-config.yaml

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,41 @@
11
repos:
2-
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.0.292
4-
hooks:
5-
- id: ruff
6-
args: [--fix, --exit-non-zero-on-fix]
7-
- repo: https://github.com/psf/black
8-
rev: 23.9.1
2+
3+
- repo: local
94
hooks:
5+
- id: pyproject-fmt
6+
name: pyproject-fmt
7+
entry: uv run pyproject-fmt pyproject.toml
8+
language: system
9+
pass_filenames: false
10+
11+
- id: uv-lock
12+
name: uv lock
13+
entry: uv lock
14+
language: system
15+
pass_filenames: false
16+
17+
- id: ruff-check
18+
name: ruff-check
19+
entry: uv run ruff check --fix --exit-non-zero-on-fix
20+
language: system
21+
pass_filenames: false
22+
23+
# A proposal to replace black & pylint
24+
# - id: ruff-format
25+
# name: ruff-format
26+
# entry: uv run ruff format --exit-non-zero-on-fix
27+
# language: system
28+
# pass_filenames: false
29+
1030
- id: black
11-
args:
12-
- --quiet
31+
name: black
32+
entry: uv run black .
33+
language: system
34+
pass_filenames: false
35+
36+
- id: pylint
37+
name: pylint
38+
entry: uv run pylint office365
39+
language: system
40+
pass_filenames: false
41+

CONTRIBUTING.md

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Welcome Contributors! 🎉
1+
# Welcome Contributors! 🎉
22

33
Thank you for your interest in contributing to the Office365-REST-Python-Client library. This project provides a comprehensive Python client for Microsoft 365 and Microsoft Graph APIs.
44

@@ -34,26 +34,17 @@ cd Office365-REST-Python-Client
3434

3535
## Development Environment Setup
3636

37-
### Virtual Environment
37+
Activate the Virtual Environment and install dependencies:
3838

3939
```bash
40-
python3 -m venv venv
41-
. venv/bin/activate # On Windows: venv\Scripts\activate
42-
```
43-
44-
### Install Dependencies
45-
46-
```bash
47-
pip install -r requirements.txt
48-
pip install -r requirements-dev.txt
40+
uv sync --all-extras
4941
```
5042

5143
### Pre-commit hooks (recommended)
5244

5345
```bash
54-
pip install pre-commit
55-
pre-commit install
56-
pre-commit run -a
46+
uv tool install prek
47+
prek run --all-files
5748
```
5849

5950
## Code Style and Quality Standards
@@ -69,9 +60,7 @@ Line length: 121 characters (configured in `pyproject.toml`).
6960
Run locally before pushing:
7061

7162
```bash
72-
black .
73-
ruff check .
74-
pylint office365
63+
prek
7564
```
7665

7766
## Testing Guidelines
@@ -82,15 +71,15 @@ Most tests are end-to-end and require actual Microsoft 365 credentials.
8271

8372
1. Create a `.env` file in the project root:
8473

85-
```bash
86-
export office365_python_sdk_securevars='{username};{password};{client_id};{client_secret}'
87-
```
74+
```bash
75+
export office365_python_sdk_securevars='{username};{password};{client_id};{client_secret}'
76+
```
8877

8978
2. Source the environment file:
9079

91-
```bash
92-
. .env
93-
```
80+
```bash
81+
. .env
82+
```
9483

9584
Note: The order of values is significant because tests parse by index.
9685

@@ -128,9 +117,9 @@ CI note: Full E2E tests in CI rely on repository secrets and may not run on fork
128117

129118
1. Create a feature branch from `master`:
130119

131-
```bash
132-
git checkout -b feature/your-feature-name
133-
```
120+
```bash
121+
git checkout -b feature/your-feature-name
122+
```
134123

135124
2. Make your changes with clear, focused commits
136125
3. Ensure all tests pass and quality checks are satisfied
@@ -180,5 +169,3 @@ This project is maintained by the community. Be respectful and constructive in a
180169
### License
181170

182171
MIT License. By contributing, you agree that your contributions are licensed under these terms.
183-
184-

README-dev.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
11
# Installing to virtualenv
2-
In the pipenv/poetry era one would already forget these commands...
32

43
```bash
5-
$ python3 -m venv venv
6-
$ . venv/bin/activate
7-
$ pip install -r requirements.txt
8-
$ pip install -r requirements-dev.txt
4+
uv sync
95
```
106

11-
# Running tests
7+
## Running tests
128

13-
Most of the tests are end-to-end - operations are invoked against actual tenant (not mocked).
14-
So one has to configure his/her office/sharepoint credentials.
9+
Most of the tests are end-to-end - operations are invoked against actual tenant (not mocked).
10+
So one has to configure his/her office/sharepoint credentials.
1511
To do so, create a file ```.env``` like this (replace the bracketed values by your values):
1612

17-
```
13+
```bash
1814
export office365_python_sdk_securevars='{username};{password};{client_id};{client_secret}'
1915
```
2016

2117
This file is in .gitignore, so it will never be committed.
2218

2319
```bash
24-
$ . .env # source it to export the variable
25-
$ pytest ... # run the test(s) you need...
20+
. .env # source it to export the variable
21+
pytest ... # run the test(s) you need...
2622
```
2723

28-
#### Configure Tenant
24+
## Configure Tenant
2925

3026
Roles:
3127

examples/sharepoint/files/download_from_lib.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
download_root_path = Path(tempfile.mkdtemp())
2323

2424
for item in items:
25-
2625
download_path = download_root_path / item.properties.get("FileDirRef").lstrip("/")
2726
download_path.mkdir(parents=True, exist_ok=True)
2827

generator/generate_model.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
from generator import load_settings
32
from generator.builders.type_builder import TypeBuilder
43
from office365.runtime.odata.v3.metadata_reader import ODataV3Reader

office365/azure_env.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
class AzureEnvironment(object):
2-
32
Global = "Global"
43
"""Referred to as Azure or Azure Global."""
54

office365/directory/serviceprincipals/service_principal.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ def _get_application_permissions(app_id):
259259
return_type.value.add(app_role)
260260

261261
def _resolve_app():
262-
263262
def _after(service_principal):
264263
_get_application_permissions(service_principal.id)
265264

0 commit comments

Comments
 (0)