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

Use Pydantic to generate and validate CodeTF data models #357

Merged
merged 3 commits into from
Mar 12, 2024

Conversation

drdavella
Copy link
Member

@drdavella drdavella commented Mar 11, 2024

Overview

Use pydantic to generate and validate CodeTF models

Description

  • Using pydantic is a good way to express data models using type hints and to enable validation
  • This enables straightforward representation of the CodeTF data model and provides JSON generation for free
  • These changes mean our data model is now precisely aligned with the CodeTF spec
  • Now that we have a JSON Schema for CodeTF I added validation for our integration tests: https://github.com/pixee/codemodder-specs/blob/main/codetf.schema.json

Copy link

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@drdavella drdavella marked this pull request as ready for review March 11, 2024 20:27
import requests


@pytest.fixture(scope="module")
Copy link
Contributor

Choose a reason for hiding this comment

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

This new fixture means every time a test module runs we're making a request. I see this is also defined below, so now both unit tests and integration tests rely on internet connectivity. Just pointing that out.
Do we need it per module, or could this fixture run per test run session only?

Copy link
Member Author

Choose a reason for hiding this comment

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

@clavedeluna good catch. I did think about making it session scoped but I think we're running unit tests and integration tests in separate workflows so it would run twice anyway.

references: Optional[list[Reference]] = None
properties: Optional[dict] = None
failedFiles: Optional[list[str]] = None
changeset: list[ChangeSet]
Copy link
Contributor

Choose a reason for hiding this comment

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

should this have = []?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm I don't think it's strictly necessary since this is a required field but it might be a good idea.

@drdavella drdavella added this pull request to the merge queue Mar 12, 2024
Merged via the queue into main with commit 658bc91 Mar 12, 2024
11 checks passed
@drdavella drdavella deleted the pydantic-codetf branch March 12, 2024 14:12
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.

3 participants