Skip to content

Commit

Permalink
Resolve Ruff issues (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-cooney authored Nov 5, 2023
1 parent f981f61 commit 8c7fa12
Show file tree
Hide file tree
Showing 34 changed files with 873 additions and 603 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARG USER_GID=$USER_UID
# https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& usermod -a -G video user \
&& usermod -a -G video user \
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
Expand Down
44 changes: 1 addition & 43 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.238.1/containers/python-3
{
"name": "Python 3",
"build": {
Expand All @@ -12,46 +10,6 @@
"--gpus",
"all"
],
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"mypy.dmypyExecutable": "dmypy"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"christian-kohler.path-intellisense",
"davidanson.vscode-markdownlint",
"donjayamanne.githistory",
"donjayamanne.python-extension-pack",
"github.copilot",
"github.vscode-github-actions",
"github.vscode-pull-request-github",
"ionutvmi.path-autocomplete",
"matangover.mypy",
"mikoz.autoflake-extension",
"ms-python.black-formatter",
"ms-python.isort",
"ms-python.pylint",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter-keymap",
"ms-toolsai.jupyter-renderers",
"ms-toolsai.jupyter",
"ms-vsliveshare.vsliveshare-pack",
"njpwerner.autodocstring",
"richie5um2.vscode-sort-json",
"stkb.rewrap",
"streetsidesoftware.code-spell-checker-british-english",
"streetsidesoftware.code-spell-checker",
"tushortz.python-extended-snippets",
"yzhang.markdown-all-in-one"
]
}
},
"containerUser": "user",
// Install any dependencies
"postCreateCommand": "poetry env use 3.11 && poetry install --with dev,jupyter"
}
}
19 changes: 11 additions & 8 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: Checks

on:
push:
branches:
branches:
- main
paths-ignore:
- '.devcontainer/**'
- '.vscode/**'
- '.gitignore'
- 'README.md'
pull_request:
branches:
branches:
- main
paths-ignore:
- '.devcontainer/**'
Expand All @@ -35,21 +35,24 @@ jobs:
- "3.10"
- "3.11"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
allow-prereleases: true
- name: Install dependencies
run: poetry install --with dev
- name: Pytest
run: poetry run pytest
- name: Pyright type check
run: poetry run pyright
- name: Ruff (lint & format)
run: poetry run ruff --check sparse_autoencoder
- name: Ruff lint
run: poetry run ruff check sparse_autoencoder --output-format=github
- name: Ruff format
run: poetry run ruff format sparse_autoencoder --check
- name: Pytest
run: poetry run pytest
- name: Build check
run: poetry build
run: poetry build
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Parse semver string
id: semver_parser
id: semver_parser
uses: booxmedialtd/[email protected]
with:
input_string: ${{ github.event.release.tag_name }}
Expand Down Expand Up @@ -51,4 +51,4 @@ jobs:
- name: Publish
run: poetry publish
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.POETRY_PYPI_TOKEN }}
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.POETRY_PYPI_TOKEN }}
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-json
- id: check-added-large-files
- id: check-merge-conflict
- id: check-symlinks
- id: destroyed-symlinks
- id: detect-private-key
- repo: local
hooks:
- id: ruff_lint
name: Ruff Lint
entry: poetry run ruff check sparse_autoencoder
language: system
types: [python]
require_serial: true
- id: ruff_format
name: Ruff Format
entry: poetry run ruff format sparse_autoencoder --check
language: system
types: [python]
require_serial: true
- id: typecheck
name: Pyright Type Check
entry: poetry run pyright
language: system
types: [python]
require_serial: true
11 changes: 9 additions & 2 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,28 @@
"language": "en,en-GB",
"words": [
"allclose",
"astroid",
"autocast",
"Autoencoder",
"autoencoder",
"categoricalwprobabilities",
"circuitsvis",
"colab",
"cuda",
"cudnn",
"davidanson",
"devcontainer",
"devel",
"dmypy",
"docstrings",
"donjayamanne",
"dtype",
"dunder",
"earlyterminate",
"einops",
"endoftext",
"gelu",
"Hobbhahn",
"githistory",
"hobbhahn",
"hyperband",
"imageuri",
"imputewhilerunning",
Expand All @@ -41,6 +46,7 @@
"nelement",
"numel",
"optim",
"penality",
"polysemantic",
"polysemantically",
"pyproject",
Expand All @@ -59,6 +65,7 @@
"sharded",
"tqdm",
"transformer_lens",
"typecheck",
"uncopyrighted",
"unsqueeze",
"venv",
Expand Down
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
"kevinrose.vsc-python-indent",
"donjayamanne.python-environment-manager"
]
}
}
42 changes: 36 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,44 @@
{
"rewrap.autoWrap.enabled": true,
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff"
},
"[toml]": {
"editor.defaultFormatter": "tamasfe.even-better-toml"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": true
},
"rewrap.reformat": false,
"editor.formatOnSave": true,
"python.testing.pytestEnabled": true,
"rewrap.wrappingColumn": 100,
"evenBetterToml.formatter.alignComments": true,
"evenBetterToml.formatter.alignEntries": true,
"evenBetterToml.formatter.allowedBlankLines": 2,
"evenBetterToml.formatter.arrayAutoCollapse": true,
"evenBetterToml.formatter.arrayAutoExpand": true,
"evenBetterToml.formatter.arrayTrailingComma": true,
"evenBetterToml.formatter.columnWidth": 100,
"evenBetterToml.formatter.compactArrays": true,
"evenBetterToml.formatter.compactEntries": true,
"evenBetterToml.formatter.compactInlineTables": true,
"evenBetterToml.formatter.indentEntries": true,
"evenBetterToml.formatter.indentTables": true,
"evenBetterToml.formatter.inlineTableExpand": false,
"evenBetterToml.formatter.reorderArrays": true,
"evenBetterToml.formatter.reorderKeys": true,
"evenBetterToml.formatter.trailingNewline": true,
"notebook.formatOnCellExecution": true,
"notebook.formatOnSave.enabled": true,
"editor.defaultFormatter": "charliermarsh.ruff",
}
"python.analysis.autoFormatStrings": true,
"python.analysis.autoImportCompletions": true,
"python.analysis.inlayHints.functionReturnTypes": false,
"python.analysis.typeCheckingMode": "basic",
"python.languageServer": "Pylance",
"python.terminal.activateEnvInCurrentTerminal": true,
"python.testing.pytestEnabled": true,
"rewrap.autoWrap.enabled": true,
"rewrap.reformat": true,
"rewrap.wrappingColumn": 100
}
Loading

0 comments on commit 8c7fa12

Please sign in to comment.