Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 29, 2025

Reduces ignored ruff rules by fixing all E731 violations ("do not assign a lambda expression, use a def").

Changes

  • apex/contrib/openfold_triton/layer_norm.py: Convert 3 grid lambda assignments to def functions
  • apex/contrib/openfold_triton/mha.py: Convert 2 grid lambda assignments to def functions
  • examples/imagenet/main_amp.py: Convert collate_fn lambda to def function
  • pyproject.toml: Remove E731 from ignore list

Example

# Before
grid = lambda kwargs: (triton.cdiv(kwargs["M"], kwargs["M_BLOCK"]),)

# After
def grid(kwargs):
    return (triton.cdiv(kwargs["M"], kwargs["M_BLOCK"]),)
Original prompt

This section details on the original issue you should resolve

<issue_title>Reduce the number of ignored rules</issue_title>
<issue_description>Create a pull request per ignored rule listed in

apex/pyproject.toml

Lines 8 to 25 in 87868b0

[tool.ruff]
line-length = 100
ignore = [
# Sorted by occurrence count (ascending) - easier to fix first
"E731", # lambda assignment (6 occurrences)
"E721", # type comparison should use isinstance (8 occurrences)
"E741", # ambiguous variable name (8 occurrences)
"E712", # comparison to True/False (9 occurrences)
"F403", # star imports used (9 occurrences)
"E701", # multiple statements on one line (10 occurrences)
"E711", # comparison to None should be `cond is None` (11 occurrences)
"F821", # undefined name (14 occurrences)
"E722", # bare except (15 occurrences)
"E402", # module level import not at top of file (41 occurrences)
"F401", # imported but unused (45 occurrences)
"F841", # local variable assigned but never used (52 occurrences)
"F405", # star imports (80 occurrences)
]
</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: crcrpar <16191443+crcrpar@users.noreply.github.com>
Copilot AI changed the title [WIP] Create pull requests for each ignored rule Fix E731: Convert lambda assignments to def functions Nov 29, 2025
Copilot AI requested a review from crcrpar November 29, 2025 02:56
Copilot finished work on behalf of crcrpar November 29, 2025 02:57
@crcrpar
Copy link
Collaborator

crcrpar commented Nov 29, 2025

pre-commit.ci autofix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce the number of ignored rules

2 participants