Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ruff config #329

Merged
merged 2 commits into from
Dec 12, 2023
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
5 changes: 5 additions & 0 deletions .changeset/purple-chefs-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@spear-ai/ruff-config": patch
---

Add Ruff config.
6 changes: 6 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,9 @@ updates:
package-ecosystem: npm
schedule:
interval: monthly
- directory: /packages/ruff-config
labels:
- 🌋 technical debt
package-ecosystem: pip
schedule:
interval: monthly
7 changes: 7 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,18 @@ jobs:
uses: actions/[email protected]
with:
fetch-depth: 2
- name: Install Poetry
run: pipx install poetry
- name: Setup Node.js
uses: actions/[email protected]
with:
cache: yarn
node-version-file: .node-version
- name: Setup Python
uses: actions/[email protected]
with:
cache: poetry
python-version-file: .python-version
- name: Install Node.js dependencies
run: yarn install --check-cache --immutable --immutable-cache
- name: Build
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
jobs:
Expand All @@ -18,11 +19,19 @@ jobs:
steps:
- name: Checkout repository
uses: actions/[email protected]
- name: Install Poetry
run: pipx install poetry
- name: Setup Node.js
uses: actions/[email protected]
with:
cache: yarn
fetch-depth: 0
node-version-file: .node-version
- name: Setup Python
uses: actions/[email protected]
with:
cache: poetry
python-version-file: .python-version
- name: Install Node.js dependencies
run: yarn install
- name: Build packages
Expand All @@ -43,5 +52,6 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
with:
title: Release 🚀
version: yarn run version
commit: Release 🚀
publish: yarn run publish-packages
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .yarn/install-state.gz
Binary file not shown.
9 changes: 9 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-after-install.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable */
//prettier-ignore
module.exports = {
name: "@yarnpkg/plugin-after-install",
factory: function (require) {
"use strict";var plugin=(()=>{var s=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var r=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(o,e)=>(typeof require<"u"?require:o)[e]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var I=(t,o)=>{for(var e in o)s(t,e,{get:o[e],enumerable:!0})},h=(t,o,e,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of x(o))!C.call(t,n)&&n!==e&&s(t,n,{get:()=>o[n],enumerable:!(a=g(o,n))||a.enumerable});return t};var k=t=>h(s({},"__esModule",{value:!0}),t);var P={};I(P,{default:()=>y});var d=r("@yarnpkg/core");var f=r("@yarnpkg/core"),c={afterInstall:{description:"Hook that will always run after install",type:f.SettingsType.STRING,default:""}};var p=r("clipanion"),u=r("@yarnpkg/core");var m=r("@yarnpkg/shell"),l=async(t,o)=>{let e=t.get("afterInstall"),a=!!t.projectCwd?.endsWith(`dlx-${process.pid}`);return e&&!a?(o&&console.log("Running `afterInstall` hook..."),(0,m.execute)(e,[],{cwd:t.projectCwd||void 0})):0};var i=class extends p.Command{async execute(){let o=await u.Configuration.find(this.context.cwd,this.context.plugins);return l(o,!1)}};i.paths=[["after-install"]];var w={configuration:c,commands:[i],hooks:{afterAllInstalled:async(t,o)=>{if(o?.mode===d.InstallMode.UpdateLockfile)return;if(await l(t.configuration,!0))throw new Error("The `afterInstall` hook failed, see output above.")}}},y=w;return k(P);})();
return plugin;
}
};
5 changes: 5 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
afterInstall: yarn workspaces foreach -A run postinstall
compressionLevel: mixed
enableGlobalCache: false
nodeLinker: node-modules
npmPublishAccess: public
plugins:
- checksum: 0a2a35fbed2f33f0df1ceb1db51bf72554201f994eaecb86cbc62a295c3d05f7cc44fa8be8e64fc5e1c0bee4f529a17a0cc429ea9e3486ad467443291d5a8e3b
path: .yarn/plugins/@yarnpkg/plugin-after-install.cjs
spec: "https://raw.githubusercontent.com/mhassan1/yarn-plugin-after-install/v0.6.0/bundles/@yarnpkg/plugin-after-install.js"
supportedArchitectures:
cpu:
- current
Expand Down
1 change: 1 addition & 0 deletions npmpackagejsonlint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ module.exports = {
rules: {
"prefer-absolute-version-dependencies": "off",
"prefer-absolute-version-devDependencies": "off",
"prefer-alphabetical-scripts": "off",
},
};
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"husky": "8.0.3",
"npm-package-json-lint": "7.1.0",
"prettier": "3.1.1",
"turbo": "1.11.1",
"turbo": "1.11.2",
"typescript": "5.3.3"
},
"license": "MIT",
Expand All @@ -31,6 +31,7 @@
"url": "https://github.com/spear-ai/citizen.git"
},
"scripts": {
"version": "changeset version && yarn workspaces foreach -A run sync-version",
"build": "yarn dlx turbo build",
"commitlint:check": "commitlint --from=HEAD^1",
"eslint:check": "eslint --max-warnings 0 .",
Expand All @@ -40,7 +41,8 @@
"npmpkgjsonlint:check": "npmPkgJsonLint .",
"prettier:check": "prettier --check .",
"prettier:fix": "prettier --write .",
"publish-packages": "yarn publish-packages:npm && yarn publish-packages:github && yarn changeset tag",
"publish-packages": "yarn run publish-packages:npm && yarn run publish-packages:github && yarn run publish-packages:custom && yarn changeset tag",
"publish-packages:custom": "yarn workspaces foreach -A run publish-package",
"publish-packages:github": "npm_config_registry=https://npm.pkg.github.com changeset publish --no-git-tag",
"publish-packages:npm": "changeset publish --no-git-tag",
"typescript:check": "tsc --noEmit",
Expand Down
3 changes: 3 additions & 0 deletions packages/ruff-config/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.ruff_cache
.venv
dist
7 changes: 7 additions & 0 deletions packages/ruff-config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @spear-ai/ruff-config

## 2.0.1

### Patch Changes

- Added Ruff config.
24 changes: 24 additions & 0 deletions packages/ruff-config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# @spear-ai/ruff-config

A [Ruff](https://docs.astral.sh/ruff) config.

## Installation

```shell
poetry add -D spear_ai_ruff_config
```

## Usage

Configure `poetry.toml` to save the virtual environment to your local project:

```
[virtualenvs]
in-project = true
```

Add the following to your `ruff.toml` file:

```toml
extend = "./.venv/lib/python3.11/site-packages/spear_ai_ruff_config/config.toml"
```
12 changes: 12 additions & 0 deletions packages/ruff-config/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { baseEslintConfig, prettierConfig } from "@spear-ai/eslint-config";

/** @type {import("eslint").Linter.FlatConfig} */
const eslintConfig = [
{
ignores: ["dist", "node_modules", ".venv"],
},
...baseEslintConfig,
prettierConfig,
];

export default eslintConfig;
7 changes: 7 additions & 0 deletions packages/ruff-config/npmpackagejsonlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
extends: ["@spear-ai/npm-package-json-lint-config/spear-library"],
rules: {
"prefer-absolute-version-devDependencies": "off",
"prefer-alphabetical-scripts": "off",
},
};
49 changes: 49 additions & 0 deletions packages/ruff-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "@spear-ai/ruff-config",
"version": "2.0.0",
"description": "Spear AI Ruff config",
"author": {
"name": "Spear AI",
"email": "[email protected]",
"url": "https://spear.ai"
},
"type": "module",
"devDependencies": {
"@swc/core": "^1.3.100",
"@swc/helpers": "^0.5.3",
"@types/eslint": "8.44.8",
"@types/regenerator-runtime": "^0",
"eslint": "8.55.0",
"graphql": "16.8.1",
"npm-package-json-lint": "7.1.0",
"prettier": "3.1.1",
"react": "18.2.0",
"regenerator-runtime": "^0.14.0",
"replace-in-file": "^7.0.2",
"tailwindcss": "3.3.6",
"ts-node": "10.9.2",
"tsup": "8.0.1",
"typescript": "5.3.3"
},
"license": "MIT",
"repository": {
"type": "git",
"directory": "packages/ruff-config",
"url": "https://github.com/spear-ai/citizen.git"
},
"scripts": {
"build": "poetry build",
"eslint:check": "eslint --max-warnings 0 .",
"eslint:fix": "yarn eslint:check --fix",
"npmpkgjsonlint:check": "npmPkgJsonLint .",
"postinstall": "poetry install",
"prettier:check": "prettier --check .",
"prettier:fix": "prettier --write .",
"publish-package": "poetry publish",
"ruff-format:check": "poetry run ruff format --check .",
"ruff-format:fix": "poetry run ruff format .",
"ruff-lint:check": "poetry run ruff check .",
"ruff-lint:fix": "poetry run ruff check --fix .",
"sync-version": "ts-node sync-version.ts"
}
}
32 changes: 32 additions & 0 deletions packages/ruff-config/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/ruff-config/poetry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[virtualenvs]
in-project = true
22 changes: 22 additions & 0 deletions packages/ruff-config/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[tool.poetry]
name = "spear-ai-ruff-config"
version = "0.0.0"
description = "Spear AI Ruff config"
authors = ["Spear AI <[email protected]>"]
keywords = [
"ai",
"config",
"ruff",
"spear"
]
packages = [{ include = "spear_ai_ruff_config" }]
readme = "README.md"
repository = "https://github.com/spear-ai/citizen"

[tool.poetry.dependencies]
python = ">=3.10,<3.13"
ruff = "^0.1.7"

[build-system]
build-backend = "poetry.core.masonry.api"
requires = ["poetry-core>=1.0.0"]
1 change: 1 addition & 0 deletions packages/ruff-config/ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extend = "./spear_ai_ruff_config/config.toml"
1 change: 1 addition & 0 deletions packages/ruff-config/spear_ai_ruff_config/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Spear AI Ruff config."""
74 changes: 74 additions & 0 deletions packages/ruff-config/spear_ai_ruff_config/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
ignore = [
"COM812",
"ISC001",
"S101",
"PLR0913"
]
line-length = 120
select = [
"A",
"ANN",
"ARG",
"ASYNC",
"B",
"BLE",
"C4",
"C90",
"COM",
"D",
"DJ",
"DTZ",
"E",
"EM",
"ERA",
"EXE",
"F",
"FA",
"FBT",
"FIX",
"FLY",
"G",
"I",
"ICN",
"INP",
"INT",
"ISC",
"N",
"NPY",
"PD",
"PERF",
"PGH",
"PIE",
"PL",
"PT",
"PTH",
"PYI",
"Q",
"RET",
"RSE",
"RUF",
"S",
"SIM",
"SLF",
"SLOT",
"T10",
"T20",
"TCH",
"TD",
"TID",
"TRY",
"UP",
"W",
"YTT",
]
target-version = "py311"

[extend-per-file-ignores]
"**/test_*.py" = ["D"]
"**/tests/**/*.py" = ["D"]

[flake8-builtins]
builtins-ignorelist = ["id"]

[pydocstyle]
convention = "pep257"
12 changes: 12 additions & 0 deletions packages/ruff-config/sync-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* eslint-disable regexp/require-unicode-sets-regexp */
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable regexp/require-unicode-regexp */

import replaceInFile from "replace-in-file";
import package_ from "./package.json" assert { type: "json" };

await replaceInFile({
files: "pyproject.toml",
from: /version = "0\.0\.0"/,
to: `version = "${package_.version}"`,
});
Loading