Skip to content

fix/pyproject-and-linting#236

Open
abdimk wants to merge 2 commits intomicrosoft:mainfrom
abdimk:main
Open

fix/pyproject-and-linting#236
abdimk wants to merge 2 commits intomicrosoft:mainfrom
abdimk:main

Conversation

@abdimk
Copy link

@abdimk abdimk commented Mar 23, 2026

I wanted to contribute to this repo as a newbie, and I noticed some gaps in the linting along with a few unused imports. Here are the changes I made.

  1. pyproject.toml

    • Added dynamic field to fix setuptools configuration error:

    dynamic = ["description", "readme", "requires-python", "license", "authors", "keywords", "classifiers", "dependencies", "optional-dependencies"]

  2. experiments/llmlingua2/evaluation/eval_bbh.py

    • Removed unused variable assignment ans_ = extract_ans(answer, task_type) → extract_ans(answer, task_type)
  3. experiments/llmlingua2/evaluation/eval_gsm8k.py

    • Renamed ambiguous variable l → line throughout the parse_pred_ans function
    • Added q = None to initial variable declarations to fix undefined name error
    • Added and q is not None check before appending
  4. experiments/llmlingua2/evaluation/eval_longbench.py

    • Removed unused variable length_list from tuple unpacking
    • Removed unused variable task assignment
  5. experiments/llmlingua2/evaluation/metrics.py

    • Moved import regex to top of file (fixes E402)
    • Removed duplicate import regex from line 169
    • Changed bare except: → except Exception: (fixes E722)
  6. experiments/llmlingua2/model_training/train_roberta.py

    • Removed unused variable t = time.time() → time.time()
    • Removed unused variable labels = [label.item() for label in eval_labels]
  7. experiments/securitylingua/filter.py

    • Removed unused import typing.Dict
  8. experiments/securitylingua/label_word.py

    • Removed unused import multiprocessing
  9. experiments/securitylingua/train_roberta.py

    • Removed unused imports: time, Dict, cuda, SummaryWriter
  10. llmlingua/prompt_compressor.py

    • Removed unused import string
    • Changed type(context) == str → isinstance(context, str) (fixes E721)
    • Renamed ambiguous variables:
      • l, r → left, right (line 1224)
      • l → start_idx (line 1767)
      • l → left, r → right (lines 1801-1815)
    • Removed unused loss variable assignment in two places (lines 2179, 2358)
    • Removed commented-out code block
  11. tests/test_llmlingua.py

    • Changed bare except: → except Exception: (fixes E722)
  12. tests/test_longllmlingua.py

    • Changed bare except: → except Exception: (fixes E722)
  13. examples/Retrieval.ipynb

    • Removed unused variable instruction from assignment
  14. examples/CoT.ipynb

    • Renamed ambiguous variable l → line throughout
  15. examples/LLMLingua2.ipynb

    • Commented out duplicate import openai (second occurrence)

Note

Contribution

@abdimk
Copy link
Author

abdimk commented Mar 23, 2026

@microsoft-github-policy-service agree

@abdimk
Copy link
Author

abdimk commented Mar 23, 2026

Hey @iofu728 can you review it and would you tell me things i should focus on next time

Thank you !

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.

1 participant