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

Add more types for function arguments and return values #86

Merged
merged 4 commits into from
Feb 13, 2024

Conversation

syou6162
Copy link
Contributor

@syou6162 syou6162 commented Feb 10, 2024

resolves #79

Description

As far as I can understand from reading the code, I have assigned types to the arguments and return values of the functions.

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have opened an issue to add/update docs, or docs changes are not required/relevant for this PR

@syou6162 syou6162 force-pushed the feature/add_more_types branch 4 times, most recently from 3ebc5a2 to 04a6ed2 Compare February 10, 2024 08:41
Copy link

codecov bot commented Feb 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f553725) 100.00% compared to head (51f41f7) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #86   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           31        32    +1     
  Lines          930       959   +29     
=========================================
+ Hits           930       959   +29     

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

@syou6162 syou6162 force-pushed the feature/add_more_types branch 4 times, most recently from dd45050 to 49b2e6b Compare February 10, 2024 09:03
from dbt_artifacts_parser.parsers.manifest.manifest_v10 import ManifestV10
from dbt_artifacts_parser.parsers.manifest.manifest_v11 import ManifestV11

Manifest = Union[
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it would be best if dbt_artifacts_parser provided these types :)

Copy link
Owner

Choose a reason for hiding this comment

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

@syou6162 hmm maybe good to make a pull request to dbt_artifacts_parser?!
I'm just concerning that this Union of all versions, that will get burden of dbterd side which will require a change to align with dbt_artifacts_parser. This is also a reason why we relax its version here.

Do you have any ideas to avoid that? Thanks

Copy link
Contributor Author

@syou6162 syou6162 Feb 10, 2024

Choose a reason for hiding this comment

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

@datnguye I think your concern is valid.

OK, I understand. I will try to send a pull request to dbt-artifacts-parser to provide these types. However, it may take some time for the pull request to be reviewed or incorporated into the new version. In my experience, it often takes a long time to be reviewed. By the way, this repository is very helpful for me as a contributor because reviews are done quickly 👍.

When a third party like me is involved in the development, it is a big help to have types in the arguments and return values of functions using mypy. So how about proceeding in this way?

  • Type definition using Union in dbterd (this pull request)
  • Send a pull request to dbt-artifacts-parser to add the Union type definition, and it will be included in the new version.
  • Replace the types defined in dbterd with the types defined in dbt-artifacts-parser

If you have difficulty accepting this proposal, I will add a new commit to remove the type definitions for Manifest and Catalog for now. However, it is the type definitions for Manifest and Catalog that I originally mainly wanted to add 😭

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@datnguye I have done some investigation and will add a note. It is possible to get the return type of a function via mypy, but it is not a good idea since it is displayed as Any on IDEs like VSCode, and it is not easy to get to the type definition. It seems that this type information can only be obtained at runtime.

from typing import get_type_hints, TypeAlias
from dbt_artifacts_parser.parser import parse_manifest

Manifest: TypeAlias = get_type_hints(parse_manifest).get("return")
tmp: Manifest
スクリーンショット 2024-02-11 1 22 00

Copy link
Owner

Choose a reason for hiding this comment

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

Thanks @syou6162 I think I will be convinced by current impl, but let me take a look further until Tuesday. If we can not see any alternatives, lets merge it right away and tag v1.11.0b2.

The major 1.11.0 should be available by end of next week 👍 🏃

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just FYI, I have submitted a pull request to dbt-artifacts-parser to provide a type using Union.

@syou6162 syou6162 changed the title WIP: Add more types for function arguments and return values Add more types for function arguments and return values Feb 10, 2024
@syou6162 syou6162 marked this pull request as ready for review February 10, 2024 09:08
@datnguye datnguye merged commit 4db04d2 into datnguye:main Feb 13, 2024
12 checks passed
@syou6162 syou6162 deleted the feature/add_more_types branch February 13, 2024 07:23
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.

[FEAT] Add more types with mypy
2 participants