Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix formatting/typing so pre-commit hooks pass #1451

Merged
merged 11 commits into from
Jan 10, 2024

Conversation

ianmckenzie-oai
Copy link
Contributor

(Not an eval)

One-line summary: Pre-commit hooks were failing. I identified the main cause, and then fixed all secondary pre-commit issues. I only changed the logic in one place, oiaevalset.py.

I was having issues with type-hinting and identified that the old typings directory was causing the from openai import OpenAI import to register as an error. I decided to go through and fix all the issues that appeared in pre-commit run --all-files.

NOTE:

  • I changed the logic in oaievalset.py by adding a continue statement if an eval or eval.key was missing.
    • As far as I can tell this should basically never happen, but is correct behavior.
    • Another option would be to assert that eval and eval.key are not None but forcing an error here doesn't match what I interpret as intended behavior.

The manual work involved was mainly:

  1. Deleting the typings directory, which was interfering with openai type-hints (such as from openai import OpenAI)
  2. Fixing type issues in oaievalset.py.
  3. Moving the client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY")) line below all the imports.
  4. Breaking lines of length >767 into smaller chunks using line continuation.

Thus this PR is broken into three parts:

  1. Deleting typings (first commit)
  2. Manually cleaning up issues (middle commits)
  3. Applying autofixes from the pre-commit hooks (last commit)

Copy link
Collaborator

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks for the cleanup! I'll add in a CI check that runs pre-commit to ensure we don't add in new issues

@etr2460 etr2460 merged commit c66b5c1 into openai:main Jan 10, 2024
2 checks passed
Linmj-Judy pushed a commit to TablewareBox/evals that referenced this pull request Feb 27, 2024
(Not an eval)

**One-line summary**: Pre-commit hooks were failing. I identified the
main cause, and then fixed all secondary pre-commit issues. I only
changed the logic in one place, `oiaevalset.py`.

I was having issues with type-hinting and identified that the old
`typings` directory was causing the `from openai import OpenAI` import
to register as an error. I decided to go through and fix all the issues
that appeared in `pre-commit run --all-files`.

NOTE: 
- I changed the logic in `oaievalset.py` by adding a `continue`
statement if an `eval` or `eval.key` was missing.
- As far as I can tell this should basically never happen, but is
correct behavior.
- Another option would be to assert that `eval` and `eval.key` are not
`None` but forcing an error here doesn't match what I interpret as
intended behavior.

The manual work involved was mainly:

1. Deleting the `typings` directory, which was interfering with `openai`
type-hints (such as `from openai import OpenAI`)
2. Fixing type issues in `oaievalset.py`.
3. Moving the `client =
OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))` line below all the
imports.
4. Breaking lines of length >767 into smaller chunks using line
continuation.

Thus this PR is broken into three parts:

1. Deleting `typings` (first commit)
2. Manually cleaning up issues (middle commits)
3. Applying autofixes from the pre-commit hooks (last commit)
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.

None yet

2 participants