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

[DOC] Update adding_typehints.md #2433

Closed
wants to merge 1 commit into from

Conversation

vedpawar2254
Copy link
Contributor

added "from future import annotations" to adding_typehints.md

Reference Issues/PRs

Fixes #1857 and update to PR #2424

What does this implement/fix? Explain your changes.

added "from future import annotations" to adding_typehints.md so that Python doesn't try to evaluate it until it's necessary

PR checklist

For all contributions
  • I've added myself to the list of contributors. Alternatively, you can use the @all-contributors bot to do this for you.
  • The PR title starts with either [ENH], [MNT], [DOC], [BUG], [REF], [DEP] or [GOV] indicating whether the PR topic is related to enhancement, maintenance, documentation, bugs, refactoring, deprecation or governance.

added "from __future__ import annotations" to adding_typehints.md
@aeon-actions-bot
Copy link
Contributor

Thank you for contributing to aeon

I did not find any labels to add based on the title. Please add the [ENH], [MNT], [BUG], [DOC], [REF], [DEP] and/or [GOV] tags to your pull requests titles. For now you can add the labels manually.

The Checks tab will show the status of our automated tests. You can click on individual test runs in the tab or "Details" in the panel below to see more information if there is a failure.

If our pre-commit code quality check fails, any trivial fixes will automatically be pushed to your PR unless it is a draft.

Don't hesitate to ask questions on the aeon Slack channel if you have any.

PR CI actions

These checkboxes will add labels to enable/disable CI functionality for this PR. This may not take effect immediately, and a new commit may be required to run the new configuration.

  • Run pre-commit checks for all files
  • Run mypy typecheck tests
  • Run all pytest tests and configurations
  • Run all notebook example tests
  • Run numba-disabled codecov tests
  • Stop automatic pre-commit fixes (always disabled for drafts)
  • Disable numba cache loading
  • Push an empty commit to re-run CI checks

@vedpawar2254
Copy link
Contributor Author

@SebastianSchmidl is this what i had to do

@vedpawar2254 vedpawar2254 changed the title Update adding_typehints.md [DOC] Update adding_typehints.md Dec 9, 2024
@SebastianSchmidl
Copy link
Member

Dear @vedpawar2254,

Can you expand the explanation to include the considerations, we discussed in Slack?

  • problem of typing soft-dependencies: the libraries/dependencies are potentially not available during runtime (having an import and reference to it would raise an error during import)
  • using both the TYPE_CHECKING constant and the annotations-import to allow type-checking and annotating
    • TYPE_CHECKING to conditionally import types from soft-deps
    • annotations-import to use them

The example is also still incorrect.

    def _is_pyod_model(model: Any) -> bool:
        """Check if the provided model is a PyOD model."""
        from pyod.models.base import BaseDetector
        return isinstance(model, BaseDetector)

is completely unrelated.

The __init__-function actually uses the BaseDetector type from pyod. Please change the example and reference the important parts from the text.

@vedpawar2254
Copy link
Contributor Author

Yeah definitely, you are right I'll do that

@MatthewMiddlehurst MatthewMiddlehurst added the documentation Improvements or additions to documentation label Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DOC] Write developer documentation for type hints including soft dependencies.
3 participants