Skip to content

feat: add Type hints for examples/keras_api_example.py#131

Open
Neerajpathak07 wants to merge 6 commits intogoogle-deepmind:mainfrom
Neerajpathak07:type-hints-keras_api_example
Open

feat: add Type hints for examples/keras_api_example.py#131
Neerajpathak07 wants to merge 6 commits intogoogle-deepmind:mainfrom
Neerajpathak07:type-hints-keras_api_example

Conversation

@Neerajpathak07
Copy link
Contributor

@Neerajpathak07 Neerajpathak07 commented Jan 27, 2026

Resolves #124

This PR adds a type hint for the examples file keras_api_example.py.
Optimizing the function from:-

def get_model():

def load_data():

to:-

def get_model() -> keras.Model:
  """Builds and returns the CNN model."""

def load_data() -> Tuple[
    Tuple[np.ndarray, np.ndarray],
    Tuple[np.ndarray, np.ndarray],
]:

else:
print("Non-DP training")
model.compile(
loss="categorical_crossentropy", optimizer="adam", metrics=["accuracy"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is lint complaining about this? If this fits under the line limit then I'd reverse this change

Copy link
Contributor Author

@Neerajpathak07 Neerajpathak07 Feb 11, 2026

Choose a reason for hiding this comment

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

Ran this locally and at the upstream CI for lint turns out it runs clean so no need to change this.

@codecov-commenter
Copy link

codecov-commenter commented Feb 11, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@512a758). Learn more about missing BASE report.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #131   +/-   ##
=======================================
  Coverage        ?   71.67%           
=======================================
  Files           ?       25           
  Lines           ?     2655           
  Branches        ?        0           
=======================================
  Hits            ?     1903           
  Misses          ?      752           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Neerajpathak07
Copy link
Contributor Author

@ryan112358 Have updated the import orders on these as well.
PS:- the CI unit test error has also been resolved for all the downstream open PR's

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.

[RFC]: add Type hints across examples/ directory. (tracking issue)

4 participants

Comments