Skip to content

Commit

Permalink
Fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelzw committed Jul 29, 2023
1 parent c9a219e commit 5f4f8d8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
report-title: Unit tests Linux - Python ${{ matrix.PYTHON_VERSION }}

pre-commit-checks:
# TODO: switch to pixi once there is a good way
name: pre-commit
timeout-minutes: 30
runs-on: ubuntu-latest
Expand All @@ -59,7 +60,7 @@ jobs:
uses: pre-commit/[email protected]

lint-workflow-files:
name: "Lint workflow files"
name: Lint workflow files
runs-on: ubuntu-latest
steps:
- name: Checkout branch
Expand Down
3 changes: 3 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ platforms = ["osx-arm64", "linux-64", "osx-64"]
[tasks]
"postinstall" = "pip install --no-build-isolation --no-deps --disable-pip-version-check -e ."
"test" = "python polarify/test.py"
"lint" = "pre-commit run --all"

[dependencies]
python = ">= 3.9"
Expand All @@ -20,3 +21,5 @@ python = ">= 3.9"
"pytest" = "*"
"pytest-md" = "*"
"pytest-emoji" = "*"
# linting
"pre-commit" = "*"
7 changes: 4 additions & 3 deletions polarify/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ def polarify(func):
source = inspect.getsource(func)
print(source)
tree = ast.parse(source)
expr = parse_body(tree.body[0].body)
func_def: ast.FunctionDef = tree.body[0] # type: ignore
expr = parse_body(func_def.body)

# Replace the body of the function with the parsed expr
tree.body[0].body = [ast.Return(expr)]
func_def.body = [ast.Return(expr)]
# TODO: make this prettier
tree.body[0].decorator_list = []
func_def.decorator_list = []

# Unparse the modified AST back into source code
new_func_code = ast.unparse(tree)
Expand Down

0 comments on commit 5f4f8d8

Please sign in to comment.