Skip to content

Commit b977e3c

Browse files
committed
remove workspace config
1 parent c8950f5 commit b977e3c

19 files changed

+167
-192
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Formatting, Linting, and Type Checking for CLI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
type-check-cli:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
token: ${{ secrets.GITHUB_TOKEN }}
18+
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v5
21+
22+
- name: install poetry as a tool
23+
run: uv tool install poetry
24+
25+
- name: install dependencies
26+
run: uvx poetry install --with dev
27+
28+
- name: Run mypy on allowlist
29+
run: uvx poetry run mypy --non-interactive --config-file pyproject.toml @mypy_allowlist.txt
30+
31+
- name: Run ruff check on changed files
32+
run: |
33+
CHANGED_FILES=$(git diff --name-only origin/main -- '*.py')
34+
if [ -n "$CHANGED_FILES" ]; then
35+
uvx ruff check $CHANGED_FILES
36+
else
37+
echo "No Python files changed, skipping lint check."
38+
fi
39+
40+
- name: Run ruff format on changed files
41+
run: |
42+
CHANGED_FILES=$(git diff --name-only origin/main -- '*.py')
43+
if [ -n "$CHANGED_FILES" ]; then
44+
uvx ruff format $CHANGED_FILES
45+
else
46+
echo "No Python files changed, skipping format."
47+
fi

.github/workflows/mypy.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,6 @@ fabric.properties
254254

255255
# Mac
256256
.DS_Store
257+
258+
# VSC Workspace settings
259+
codeflash.code-workspace

codeflash.code-workspace

Lines changed: 0 additions & 80 deletions
This file was deleted.

codeflash/cli_cmds/cli_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def inquirer_wrapper_path(*args: str, **kwargs: str) -> dict[str, str] | None:
7474
new_kwargs["message"] = last_message
7575
new_args.append(args[0])
7676

77-
return cast(dict[str, str], inquirer.prompt([inquirer.Path(*new_args, **new_kwargs)]))
77+
return cast("dict[str, str]", inquirer.prompt([inquirer.Path(*new_args, **new_kwargs)]))
7878

7979

8080
def split_string_to_fit_width(string: str, width: int) -> list[str]:

codeflash/cli_cmds/cmd_init.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ def init_codeflash() -> None:
6868
did_add_new_key = prompt_api_key()
6969

7070
if should_modify_pyproject_toml():
71-
7271
setup_info: SetupInfo = collect_setup_info()
7372

7473
configure_pyproject_toml(setup_info)
@@ -81,7 +80,6 @@ def init_codeflash() -> None:
8180
if "setup_info" in locals():
8281
module_string = f" you selected ({setup_info.module_root})"
8382

84-
8583
click.echo(
8684
f"{LF}"
8785
f"⚡️ Codeflash is now set up! You can now run:{LF}"
@@ -123,29 +121,31 @@ def ask_run_end_to_end_test(args: Namespace) -> None:
123121
bubble_sort_path, bubble_sort_test_path = create_bubble_sort_file_and_test(args)
124122
run_end_to_end_test(args, bubble_sort_path, bubble_sort_test_path)
125123

124+
126125
def should_modify_pyproject_toml() -> bool:
127-
"""
128-
Check if the current directory contains a valid pyproject.toml file with codeflash config
126+
"""Check if the current directory contains a valid pyproject.toml file with codeflash config
129127
If it does, ask the user if they want to re-configure it.
130128
"""
131129
from rich.prompt import Confirm
130+
132131
pyproject_toml_path = Path.cwd() / "pyproject.toml"
133132
if not pyproject_toml_path.exists():
134133
return True
135134
try:
136135
config, config_file_path = parse_config_file(pyproject_toml_path)
137-
except Exception as e:
136+
except Exception:
138137
return True
139138

140139
if "module_root" not in config or config["module_root"] is None or not Path(config["module_root"]).is_dir():
141140
return True
142141
if "tests_root" not in config or config["tests_root"] is None or not Path(config["tests_root"]).is_dir():
143142
return True
144143

145-
create_toml = Confirm.ask(
146-
f"✅ A valid Codeflash config already exists in this project. Do you want to re-configure it?", default=False, show_default=True
144+
return Confirm.ask(
145+
"✅ A valid Codeflash config already exists in this project. Do you want to re-configure it?",
146+
default=False,
147+
show_default=True,
147148
)
148-
return create_toml
149149

150150

151151
def collect_setup_info() -> SetupInfo:
@@ -224,7 +224,7 @@ def collect_setup_info() -> SetupInfo:
224224
else:
225225
apologize_and_exit()
226226
else:
227-
tests_root = Path(curdir) / Path(cast(str, tests_root_answer))
227+
tests_root = Path(curdir) / Path(cast("str", tests_root_answer))
228228
tests_root = tests_root.relative_to(curdir)
229229
ph("cli-tests-root-provided")
230230

@@ -278,9 +278,9 @@ def collect_setup_info() -> SetupInfo:
278278
return SetupInfo(
279279
module_root=str(module_root),
280280
tests_root=str(tests_root),
281-
test_framework=cast(str, test_framework),
281+
test_framework=cast("str", test_framework),
282282
ignore_paths=ignore_paths,
283-
formatter=cast(str, formatter),
283+
formatter=cast("str", formatter),
284284
git_remote=str(git_remote),
285285
)
286286

@@ -390,7 +390,7 @@ def check_for_toml_or_setup_file() -> str | None:
390390
click.echo("⏩️ Skipping pyproject.toml creation.")
391391
apologize_and_exit()
392392
click.echo()
393-
return cast(str, project_name)
393+
return cast("str", project_name)
394394

395395

396396
def install_github_actions(override_formatter_check: bool = False) -> None:

codeflash/code_utils/code_extractor.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import ast
4-
from pathlib import Path
54
from typing import TYPE_CHECKING
65

76
import libcst as cst
@@ -11,12 +10,15 @@
1110
from libcst.helpers import calculate_module_and_package
1211

1312
from codeflash.cli_cmds.console import logger
14-
from codeflash.models.models import FunctionParent, FunctionSource
13+
from codeflash.models.models import FunctionParent
1514

1615
if TYPE_CHECKING:
16+
from pathlib import Path
17+
1718
from libcst.helpers import ModuleNameAndPackage
1819

1920
from codeflash.discovery.functions_to_optimize import FunctionToOptimize
21+
from codeflash.models.models import FunctionSource
2022

2123

2224
class FutureAliasedImportTransformer(cst.CSTTransformer):

codeflash/code_utils/config_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def parse_config_file(
8787
"In pyproject.toml, Codeflash only supports the 'test-framework' as pytest and unittest."
8888
)
8989
if len(config["formatter-cmds"]) > 0:
90-
#see if this is happening during GitHub actions setup
90+
# see if this is happening during GitHub actions setup
9191
if not override_formatter_check:
9292
assert config["formatter-cmds"][0] != "your-formatter $file", (
9393
"The formatter command is not set correctly in pyproject.toml. Please set the "

0 commit comments

Comments
 (0)