litellm icon indicating copy to clipboard operation
litellm copied to clipboard

Workflows linter and typers

Open edwinjosegeorge opened this issue 10 months ago • 7 comments

This PR is an updated version of https://github.com/BerriAI/litellm/pull/1537 in conjunction with https://github.com/BerriAI/litellm/pull/3291 for the feature https://github.com/BerriAI/litellm/issues/360 .

To summarize, these are what's happening:

  • Adding packages
    • pre-commit and mypy is added as dev dependency
    • all stub files are install as dev dependency
  • Updating workflow
    • adding black check at github workflow
    • new workflow to check type is added (initiated by https://github.com/ErikBjare)
  • Adding py.marker to indicate this project now supports type annotation as described by PEP. However there exists errors that needs to be fixed ( run mypy litellm --strict )

edwinjosegeorge avatar Apr 27 '24 15:04 edwinjosegeorge

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 29, 2024 1:56pm

vercel[bot] avatar Apr 27 '24 15:04 vercel[bot]

It seems the project is not currently black and mypy compliant. It seems lint check at github workflow is disabled.

To fix black, it would require just running black . on entire project but would results in updates on a bunch of files. side-effects -> Most of the PR might result in merge conflict??

Any views on how to implement this? @ishaan-jaff @krrishdholakia

edwinjosegeorge avatar Apr 27 '24 15:04 edwinjosegeorge

@edwinjosegeorge what do you mean?

We run black formatting on every commit

  • https://github.com/BerriAI/litellm/blob/4cccd470ab72cbc88d71204036229b39ccb8f44b/.circleci/config.yml#L73

We run mypy on every commit

  • https://github.com/BerriAI/litellm/blob/4cccd470ab72cbc88d71204036229b39ccb8f44b/.circleci/config.yml#L83

I believe you're seeing issues b/c you might be running it on the parent dir.

The parent dir includes our docs, cookbooks, etc.

krrishdholakia avatar Apr 27 '24 15:04 krrishdholakia

Hmm... I still get black warnings when I run from the main branch

> black .\litellm\
....
All done! ✨ 🍰 ✨
42 files reformatted, 218 files left unchanged.

and

> mypy .\litellm\
....
Found 13 errors in 2 files (checked 261 source files)

and

> pre-commit run mypy --all-files
...
Found 13 errors in 2 files (checked 18 source files)
...
Found 13 errors in 2 files (checked 18 source files)
...

Could you confirm the same? I did read through the config and not sure why is it not failing!! @krrishdholakia

edwinjosegeorge avatar Apr 27 '24 16:04 edwinjosegeorge

Hah! I think just running black from bash updates the codebase "within the container" and the result is not propagated back?? @krrishdholakia

edwinjosegeorge avatar Apr 27 '24 16:04 edwinjosegeorge

I have updated the command running on circleic. Earlier, the command python -m black . would reformat the code and return exit code 0. with the check flag, It will now return exit code 1 if code reformatting is needed.

I have also added black check at github workflow. Is it needed? Do we need to check for mypy and black at github workflow and circle ci? @krrishdholakia

edwinjosegeorge avatar Apr 29 '24 08:04 edwinjosegeorge

Do we need to run black and mypy at github workflow as well as circleci? Do let me know if this PR is still relevant or is expecting somemore changes. I could then resolve the merge confict.

@krrishdholakia

edwinjosegeorge avatar May 17 '24 00:05 edwinjosegeorge

@edwinjosegeorge we already run black and mypy on circle ci.

Closing this pr.

krrishdholakia avatar Jun 12 '24 17:06 krrishdholakia

hi @krrishdholakia In the circle ci, black always reformats the code. The correct command to run in circle ci is python -m black . --check instead of python -m black . Currently the project is not black compliant. Do you want to create a PR just for that?

image

edwinjosegeorge avatar Jun 12 '24 23:06 edwinjosegeorge

that sounds like a good idea, let's do that @edwinjosegeorge

Thanks!

krrishdholakia avatar Jun 12 '24 23:06 krrishdholakia