Skip to content

Commit 1248a4a

Browse files
authored
Merge branch 'main' into dependencies-update
2 parents 00473e8 + 21f09ab commit 1248a4a

20 files changed

+159
-107
lines changed

.github/workflows/codeflash-optimize.yaml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,25 @@ jobs:
2929
fetch-depth: 0
3030
- name: Validate PR
3131
run: |
32-
# Checking for any workflow changes for security risks
33-
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
34-
echo "Workflow changes detected."
32+
# Check for any workflow changes
33+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
34+
echo "⚠️ Workflow changes detected."
3535
36-
# Check if the PR author is allowed
36+
# Get the PR author
3737
AUTHOR="${{ github.event.pull_request.user.login }}"
38-
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
39-
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
40-
exit 1
38+
echo "PR Author: $AUTHOR"
39+
40+
# Allowlist check
41+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
42+
echo "✅ Authorized user ($AUTHOR). Proceeding."
43+
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
44+
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
4145
else
42-
echo "Authorized user ($AUTHOR). Proceeding."
46+
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
47+
exit 1
4348
fi
49+
else
50+
echo "✅ No workflow file changes detected. Proceeding."
4451
fi
4552
4653
- name: 🐍 Set up Python 3.11 for CLI

.github/workflows/end-to-end-test-bubblesort-pytest-no-git.yaml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,25 @@ jobs:
2424
token: ${{ secrets.GITHUB_TOKEN }}
2525
- name: Validate PR
2626
run: |
27-
# Checking for any workflow changes for security risks
28-
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
29-
echo "Workflow changes detected."
27+
# Check for any workflow changes
28+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
29+
echo "⚠️ Workflow changes detected."
3030
31-
# Check if the PR author is allowed
31+
# Get the PR author
3232
AUTHOR="${{ github.event.pull_request.user.login }}"
33-
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
34-
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
35-
exit 1
33+
echo "PR Author: $AUTHOR"
34+
35+
# Allowlist check
36+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
37+
echo "✅ Authorized user ($AUTHOR). Proceeding."
38+
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
39+
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
3640
else
37-
echo "Authorized user ($AUTHOR). Proceeding."
41+
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
42+
exit 1
3843
fi
44+
else
45+
echo "✅ No workflow file changes detected. Proceeding."
3946
fi
4047
4148
- name: Set up Python 3.11 for CLI

.github/workflows/end-to-end-test-bubblesort-unittest.yaml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,25 @@ jobs:
2424
token: ${{ secrets.GITHUB_TOKEN }}
2525
- name: Validate PR
2626
run: |
27-
# Checking for any workflow changes for security risks
28-
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
29-
echo "Workflow changes detected."
27+
# Check for any workflow changes
28+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
29+
echo "⚠️ Workflow changes detected."
3030
31-
# Check if the PR author is allowed
31+
# Get the PR author
3232
AUTHOR="${{ github.event.pull_request.user.login }}"
33-
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
34-
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
35-
exit 1
33+
echo "PR Author: $AUTHOR"
34+
35+
# Allowlist check
36+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
37+
echo "✅ Authorized user ($AUTHOR). Proceeding."
38+
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
39+
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
3640
else
37-
echo "Authorized user ($AUTHOR). Proceeding."
41+
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
42+
exit 1
3843
fi
44+
else
45+
echo "✅ No workflow file changes detected. Proceeding."
3946
fi
4047
4148
- name: Set up Python 3.11 for CLI

.github/workflows/end-to-end-test-coverage.yaml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,25 @@ jobs:
2222
token: ${{ secrets.GITHUB_TOKEN }}
2323
- name: Validate PR
2424
run: |
25-
# Checking for any workflow changes for security risks
26-
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
27-
echo "Workflow changes detected."
25+
# Check for any workflow changes
26+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
27+
echo "⚠️ Workflow changes detected."
2828
29-
# Check if the PR author is allowed
29+
# Get the PR author
3030
AUTHOR="${{ github.event.pull_request.user.login }}"
31-
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
32-
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
33-
exit 1
31+
echo "PR Author: $AUTHOR"
32+
33+
# Allowlist check
34+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
35+
echo "✅ Authorized user ($AUTHOR). Proceeding."
36+
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
37+
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
3438
else
35-
echo "Authorized user ($AUTHOR). Proceeding."
39+
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
40+
exit 1
3641
fi
42+
else
43+
echo "✅ No workflow file changes detected. Proceeding."
3744
fi
3845
3946
- name: Set up Python 3.11 for CLI

.github/workflows/end-to-end-test-futurehouse.yaml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,25 @@ jobs:
2424
token: ${{ secrets.GITHUB_TOKEN }}
2525
- name: Validate PR
2626
run: |
27-
# Checking for any workflow changes for security risks
28-
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
29-
echo "Workflow changes detected."
27+
# Check for any workflow changes
28+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
29+
echo "⚠️ Workflow changes detected."
3030
31-
# Check if the PR author is allowed
31+
# Get the PR author
3232
AUTHOR="${{ github.event.pull_request.user.login }}"
33-
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
34-
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
35-
exit 1
33+
echo "PR Author: $AUTHOR"
34+
35+
# Allowlist check
36+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
37+
echo "✅ Authorized user ($AUTHOR). Proceeding."
38+
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
39+
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
3640
else
37-
echo "Authorized user ($AUTHOR). Proceeding."
41+
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
42+
exit 1
3843
fi
44+
else
45+
echo "✅ No workflow file changes detected. Proceeding."
3946
fi
4047
4148
- name: Set up Python 3.11 for CLI

.github/workflows/end-to-end-test-init-optim.yaml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,25 @@ jobs:
2424
token: ${{ secrets.GITHUB_TOKEN }}
2525
- name: Validate PR
2626
run: |
27-
# Checking for any workflow changes for security risks
28-
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
29-
echo "Workflow changes detected."
27+
# Check for any workflow changes
28+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
29+
echo "⚠️ Workflow changes detected."
3030
31-
# Check if the PR author is allowed
31+
# Get the PR author
3232
AUTHOR="${{ github.event.pull_request.user.login }}"
33-
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
34-
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
35-
exit 1
33+
echo "PR Author: $AUTHOR"
34+
35+
# Allowlist check
36+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
37+
echo "✅ Authorized user ($AUTHOR). Proceeding."
38+
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
39+
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
3640
else
37-
echo "Authorized user ($AUTHOR). Proceeding."
41+
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
42+
exit 1
3843
fi
44+
else
45+
echo "✅ No workflow file changes detected. Proceeding."
3946
fi
4047
4148
- name: Set up Python 3.11 for CLI

.github/workflows/end-to-end-test-tracer-replay.yaml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,25 @@ jobs:
2424
token: ${{ secrets.GITHUB_TOKEN }}
2525
- name: Validate PR
2626
run: |
27-
# Checking for any workflow changes for security risks
28-
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
29-
echo "Workflow changes detected."
27+
# Check for any workflow changes
28+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
29+
echo "⚠️ Workflow changes detected."
3030
31-
# Check if the PR author is allowed
31+
# Get the PR author
3232
AUTHOR="${{ github.event.pull_request.user.login }}"
33-
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
34-
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
35-
exit 1
33+
echo "PR Author: $AUTHOR"
34+
35+
# Allowlist check
36+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
37+
echo "✅ Authorized user ($AUTHOR). Proceeding."
38+
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
39+
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
3640
else
37-
echo "Authorized user ($AUTHOR). Proceeding."
41+
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
42+
exit 1
3843
fi
44+
else
45+
echo "✅ No workflow file changes detected. Proceeding."
3946
fi
4047
4148

.github/workflows/end-to-end-topological-sort-test.yaml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,26 @@ jobs:
2222
with:
2323
fetch-depth: 0
2424
token: ${{ secrets.GITHUB_TOKEN }}
25+
2526
- name: Validate PR
2627
run: |
27-
# Checking for any workflow changes for security risks
28-
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
29-
echo "Workflow changes detected."
30-
31-
# Check if the PR author is allowed
28+
# Check for any workflow changes
29+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
30+
echo "⚠️ Workflow changes detected."
31+
# Get the PR author
3232
AUTHOR="${{ github.event.pull_request.user.login }}"
33-
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
34-
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
35-
exit 1
33+
echo "PR Author: $AUTHOR"
34+
# Allowlist check
35+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
36+
echo "✅ Authorized user ($AUTHOR). Proceeding."
37+
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
38+
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
3639
else
37-
echo "Authorized user ($AUTHOR). Proceeding."
40+
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
41+
exit 1
3842
fi
39-
fiif git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "end-to-end-topological-sort-test.yaml"; then
40-
echo "This workflow file has been modified. Exiting for security."
41-
exit 1
43+
else
44+
echo "✅ No workflow file changes detected. Proceeding."
4245
fi
4346
4447
- name: Set up Python 3.11 for CLI

codeflash/code_utils/config_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def parse_config_file(
5252
assert isinstance(config, dict)
5353

5454
# default values:
55-
path_keys = ["module-root", "tests-root"]
56-
path_list_keys = ["ignore-paths"]
55+
path_keys = {"module-root", "tests-root"}
56+
path_list_keys = {"ignore-paths", }
5757
str_keys = {"pytest-cmd": "pytest", "git-remote": "origin"}
5858
bool_keys = {"disable-telemetry": False, "disable-imports-sorting": False}
5959
list_str_keys = {"formatter-cmds": ["black $file"]}
@@ -83,7 +83,7 @@ def parse_config_file(
8383
else: # Default to empty list
8484
config[key] = []
8585

86-
assert config["test-framework"] in ["pytest", "unittest"], (
86+
assert config["test-framework"] in {"pytest", "unittest"}, (
8787
"In pyproject.toml, Codeflash only supports the 'test-framework' as pytest and unittest."
8888
)
8989
if len(config["formatter-cmds"]) > 0:

codeflash/code_utils/tabulate.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def _pipe_segment_with_colons(align, colwidth):
7070
"""Return a segment of a horizontal line with optional colons which
7171
indicate column's alignment (as in `pipe` output format)."""
7272
w = colwidth
73-
if align in ["right", "decimal"]:
73+
if align in {"right", "decimal"}:
7474
return ("-" * (w - 1)) + ":"
7575
elif align == "center":
7676
return ":" + ("-" * (w - 2)) + ":"
@@ -176,7 +176,7 @@ def _isconvertible(conv, string):
176176
def _isnumber(string):
177177
return (
178178
# fast path
179-
type(string) in (float, int)
179+
type(string) in {float, int}
180180
# covers 'NaN', +/- 'inf', and eg. '1e2', as well as any type
181181
# convertible to int/float.
182182
or (
@@ -188,7 +188,7 @@ def _isnumber(string):
188188
# just an over/underflow
189189
or (
190190
not (math.isinf(float(string)) or math.isnan(float(string)))
191-
or string.lower() in ["inf", "-inf", "nan"]
191+
or string.lower() in {"inf", "-inf", "nan"}
192192
)
193193
)
194194
)
@@ -210,7 +210,7 @@ def _isint(string, inttype=int):
210210

211211
def _isbool(string):
212212
return type(string) is bool or (
213-
isinstance(string, (bytes, str)) and string in ("True", "False")
213+
isinstance(string, (bytes, str)) and string in {"True", "False"}
214214
)
215215

216216

@@ -570,7 +570,7 @@ def _normalize_tabular_data(tabular_data, headers, showindex="default"):
570570
# values is a property, has .index => it's likely a pandas.DataFrame (pandas 0.11.0)
571571
keys = list(tabular_data)
572572
if (
573-
showindex in ["default", "always", True]
573+
showindex in {"default", "always", True}
574574
and tabular_data.index.name is not None
575575
):
576576
if isinstance(tabular_data.index.name, list):
@@ -686,7 +686,7 @@ def _normalize_tabular_data(tabular_data, headers, showindex="default"):
686686
rows = list(map(lambda r: r if _is_separating_line(r) else list(r), rows))
687687

688688
# add or remove an index column
689-
showindex_is_a_str = type(showindex) in [str, bytes]
689+
showindex_is_a_str = type(showindex) in {str, bytes}
690690
if showindex == "never" or (not _bool(showindex) and not showindex_is_a_str):
691691
pass
692692

@@ -820,7 +820,7 @@ def tabulate(
820820
if colglobalalign is not None: # if global alignment provided
821821
aligns = [colglobalalign] * len(cols)
822822
else: # default
823-
aligns = [numalign if ct in [int, float] else stralign for ct in coltypes]
823+
aligns = [numalign if ct in {int, float} else stralign for ct in coltypes]
824824
# then specific alignments
825825
if colalign is not None:
826826
assert isinstance(colalign, Iterable)
@@ -1044,4 +1044,4 @@ def _format_table(
10441044
output = "\n".join(lines)
10451045
return output
10461046
else: # a completely empty table
1047-
return ""
1047+
return ""

0 commit comments

Comments
 (0)