Skip to content

Commit 8c84320

Browse files
authored
Add initial skeleton of package, including tooling setup and CI (#4)
* Add initial skeleton of package, including tooling setup and CI * update workflow * update uv * add bandit
1 parent 118c894 commit 8c84320

File tree

10 files changed

+685
-0
lines changed

10 files changed

+685
-0
lines changed

.github/workflows/check-python.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Check Python
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
branches: ["main"]
6+
paths:
7+
- "python/**"
8+
- ".github/workflows/check-python.yml"
9+
10+
jobs:
11+
pre-commit:
12+
if: "!cancelled()"
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
python-version: ["3.10"]
17+
runs-on: ubuntu-latest
18+
continue-on-error: true
19+
defaults:
20+
run:
21+
working-directory: python
22+
env:
23+
# Configure a constant location for the uv cache
24+
UV_CACHE_DIR: /tmp/.uv-cache
25+
UV_PYTHON: ${{ matrix.python-version }}
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Set up uv
29+
uses: astral-sh/setup-uv@v5
30+
with:
31+
version: "0.7.x"
32+
enable-cache: true
33+
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
34+
cache-dependency-glob: "**/uv.lock"
35+
- name: Install the project
36+
run: uv sync --all-extras --dev
37+
- uses: pre-commit/action@v3.0.1
38+
name: Run Pre-Commit Hooks
39+
with:
40+
extra_args: --config python/.pre-commit-config.yaml --all-files

.gitignore

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# UV
98+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
#uv.lock
102+
103+
# poetry
104+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105+
# This is especially recommended for binary packages to ensure reproducibility, and is more
106+
# commonly ignored for libraries.
107+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108+
#poetry.lock
109+
110+
# pdm
111+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112+
#pdm.lock
113+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114+
# in version control.
115+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116+
.pdm.toml
117+
.pdm-python
118+
.pdm-build/
119+
120+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121+
__pypackages__/
122+
123+
# Celery stuff
124+
celerybeat-schedule
125+
celerybeat.pid
126+
127+
# SageMath parsed files
128+
*.sage.py
129+
130+
# Environments
131+
.env
132+
.venv
133+
env/
134+
venv/
135+
ENV/
136+
env.bak/
137+
venv.bak/
138+
139+
# Spyder project settings
140+
.spyderproject
141+
.spyproject
142+
143+
# Rope project settings
144+
.ropeproject
145+
146+
# mkdocs documentation
147+
/site
148+
149+
# mypy
150+
.mypy_cache/
151+
.dmypy.json
152+
dmypy.json
153+
154+
# Pyre type checker
155+
.pyre/
156+
157+
# pytype static type analyzer
158+
.pytype/
159+
160+
# Cython debug symbols
161+
cython_debug/
162+
163+
# PyCharm
164+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166+
# and can be added to the global gitignore or merged into this file. For a more nuclear
167+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
168+
#.idea/
169+
170+
# Ruff stuff:
171+
.ruff_cache/
172+
173+
# PyPI configuration file
174+
.pypirc

python/.pre-commit-config.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
fail_fast: true
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v4.6.0
5+
hooks:
6+
- id: check-toml
7+
files: \.toml$
8+
- id: check-yaml
9+
files: \.yaml$
10+
- id: check-json
11+
files: \.json$
12+
- id: end-of-file-fixer
13+
files: \.py$
14+
- id: mixed-line-ending
15+
files: \.py$
16+
- id: check-ast
17+
name: Check Valid Python Samples
18+
types: ["python"]
19+
- repo: https://github.com/nbQA-dev/nbQA
20+
rev: 1.8.5
21+
hooks:
22+
- id: nbqa-check-ast
23+
name: Check Valid Python Notebooks
24+
types: ["jupyter"]
25+
- repo: https://github.com/asottile/pyupgrade
26+
rev: v3.17.0
27+
hooks:
28+
- id: pyupgrade
29+
args: [--py310-plus]
30+
- repo: https://github.com/astral-sh/ruff-pre-commit
31+
rev: v0.9.6
32+
hooks:
33+
- id: ruff
34+
args: [ --fix, --exit-non-zero-on-fix ]
35+
- id: ruff-format
36+
- repo: https://github.com/astral-sh/uv-pre-commit
37+
# uv version.
38+
rev: 0.7.2
39+
hooks:
40+
# Update the uv lockfile
41+
- id: uv-lock
42+
files: python/pyproject.toml
43+
args: [--project, python]
44+
- repo: https://github.com/RobertCraigie/pyright-python
45+
rev: v1.1.400
46+
hooks:
47+
- id: pyright

python/.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

python/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Microsoft Corporation.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE

python/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Python
2+
3+
## Checks
4+
5+
Run all checks using pre-commit:
6+
7+
```bash
8+
uv run pre-commit run -a
9+
```

python/pyproject.toml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
[project]
2+
name = "agent-framework"
3+
readme = "README.md"
4+
requires-python = ">=3.10"
5+
version = "0.0.0"
6+
license = {file = "LICENSE"}
7+
urls.source = "https://github.com/microsoft/agent-framework/tree/main/python"
8+
dependencies = [
9+
]
10+
11+
[dependency-groups]
12+
dev = [
13+
"pre-commit >= 3.7",
14+
"pyright>=1.1.400",
15+
"mypy>=1.15.0",
16+
"ruff>=0.11.8",
17+
]
18+
19+
[build-system]
20+
requires = ["hatchling", "uv-dynamic-versioning"]
21+
build-backend = "hatchling.build"
22+
23+
24+
[tool.uv-dynamic-versioning]
25+
fallback-version = "0.0.0"
26+
27+
[tool.ruff]
28+
line-length = 120
29+
target-version = "py310"
30+
include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"]
31+
preview = true
32+
33+
[tool.ruff.lint]
34+
fixable = ["ALL"]
35+
unfixable = []
36+
select = [
37+
"ASYNC", # async checks
38+
"B", # bugbear checks
39+
"CPY", # copyright
40+
"D", # pydocstyle checks
41+
"E", # pycodestyle error checks
42+
"ERA", # remove connected out code
43+
"F", # pyflakes checks
44+
"FIX", # fixme checks
45+
"I", # isort
46+
"INP", # implicit namespace package
47+
"ISC", # implicit string concat
48+
"Q", # flake8-quotes checks
49+
"RET", # flake8-return check
50+
"RSE", # raise exception parantheses check
51+
"RUF", # RUF specific rules
52+
"SIM", # flake8-simplify check
53+
"T20", # typing checks
54+
"TD", # todos
55+
"W", # pycodestyle warning checks
56+
"T100", # Debugger,
57+
"S", # Bandit checks
58+
]
59+
ignore = [
60+
"D100", # allow missing docstring in public module
61+
"D104", # allow missing docstring in public package
62+
"TD003", # allow missing link to todo issue
63+
"FIX002" # allow todo
64+
]
65+
66+
[tool.ruff.format]
67+
docstring-code-format = true
68+
69+
[tool.ruff.lint.pydocstyle]
70+
convention = "google"
71+
72+
[tool.ruff.lint.flake8-copyright]
73+
notice-rgx = "^# Copyright \\(c\\) Microsoft\\. All rights reserved\\."
74+
min-file-size = 1
75+
76+
[tool.pyright]
77+
include = ["src", "tests", "samples"]
78+
typeCheckingMode = "strict"
79+
reportUnnecessaryIsInstance = false
80+
reportMissingTypeStubs = false
81+
venvPath = "."
82+
venv = ".venv"
83+
84+
[tool.mypy]
85+
strict = true
86+
python_version = "3.9"
87+
ignore_missing_imports = true
88+
89+
disallow_untyped_defs = true
90+
no_implicit_optional = true
91+
check_untyped_defs = true
92+
warn_return_any = true
93+
show_error_codes = true
94+
warn_unused_ignores = false
95+
96+
disallow_incomplete_defs = true
97+
disallow_untyped_decorators = true
98+
disallow_any_unimported = true

0 commit comments

Comments
 (0)