added ruff toml and pre-comit files to template if community (#477)

This reintroduces a question into `arcade new`, which adds the ruff and
pre-commit files into new toolkits that are aimed to be contributed back
to Arcade AI.

I use it in the toolkit building tutorial

---------

Co-authored-by: Evan Tahler <evantahler@gmail.com>
This commit is contained in:
Mateo Torres 2025-07-09 14:04:30 -03:00 committed by GitHub
parent de7b655214
commit a30fc9379a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 79 additions and 3 deletions

View file

@ -75,7 +75,7 @@ def write_template(path: Path, content: str) -> None:
path.write_text(content, encoding="utf-8")
def create_ignore_pattern(include_evals: bool) -> re.Pattern[str]:
def create_ignore_pattern(include_evals: bool, community_toolkit: bool) -> re.Pattern[str]:
"""Create an ignore pattern based on user preferences."""
patterns = [
"__pycache__",
@ -96,6 +96,9 @@ def create_ignore_pattern(include_evals: bool) -> re.Pattern[str]:
if not include_evals:
patterns.append("evals")
if not community_toolkit:
patterns.extend([".ruff.toml", ".pre-commit-config.yaml", "README.md"])
return re.compile(f"({'|'.join(patterns)})$")
@ -174,6 +177,16 @@ def create_new_toolkit(output_directory: str, toolkit_name: str) -> None:
"Do you want an evals directory created for you?", default=True
)
cwd = Path.cwd()
# TODO: this detection mechanism works only for people that didn't change the
# name of the repo, a better detection method is required here
community_toolkit = False
if cwd.name == "toolkits" and cwd.parent.name == "arcade-ai":
community_toolkit = ask_yes_no_question(
"Is your toolkit a community contribution (to be merged into Arcade's `arcade-ai` repo)?",
default=False, # False for now to keep the default behavior
)
context = {
"package_name": package_name,
"toolkit_name": toolkit_name,
@ -187,6 +200,7 @@ def create_new_toolkit(output_directory: str, toolkit_name: str) -> None:
"arcade_ai_min_version": ARCADE_AI_MIN_VERSION,
"arcade_ai_max_version": ARCADE_AI_MAX_VERSION,
"creation_year": datetime.now().year,
"community_toolkit": community_toolkit,
}
template_directory = Path(__file__).parent / "templates" / "{{ toolkit_name }}"
@ -196,7 +210,7 @@ def create_new_toolkit(output_directory: str, toolkit_name: str) -> None:
)
# Create dynamic ignore pattern based on user preferences
ignore_pattern = create_ignore_pattern(include_evals)
ignore_pattern = create_ignore_pattern(include_evals, community_toolkit)
try:
create_package(env, template_directory, toolkit_directory, context, ignore_pattern)

View file

@ -0,0 +1,18 @@
files: ^.*/{{toolkit_name}}/.*
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.4.0"
hooks:
- id: check-case-conflict
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.7
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

View file

@ -0,0 +1,44 @@
target-version = "py310"
line-length = 100
fix = true
[lint]
select = [
# flake8-2020
"YTT",
# flake8-bandit
"S",
# flake8-bugbear
"B",
# flake8-builtins
"A",
# flake8-comprehensions
"C4",
# flake8-debugger
"T10",
# flake8-simplify
"SIM",
# isort
"I",
# mccabe
"C90",
# pycodestyle
"E", "W",
# pyflakes
"F",
# pygrep-hooks
"PGH",
# pyupgrade
"UP",
# ruff
"RUF",
# tryceratops
"TRY",
]
[lint.per-file-ignores]
"**/tests/*" = ["S101"]
[format]
preview = true
skip-magic-trailing-comma = false

View file

@ -1,6 +1,6 @@
[project]
name = "arcade-ai"
version = "2.0.4"
version = "2.0.5"
description = "Arcade.dev - Tool Calling platform for Agents"
readme = "README.md"
license = {file = "LICENSE"}