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(mypy): fix custom Path and UUID related types #2420

Merged
merged 4 commits into from Mar 2, 2021

Conversation

PrettyWood
Copy link
Member

@PrettyWood PrettyWood commented Feb 27, 2021

Change Summary

I went a bit too far with #2099 because I was first focused on "accepted" types and not "validated" types.

Related issue number

closes #2418

Checklist

  • Unit tests for the changes exist
  • Tests pass on CI and coverage remains at 100%
  • Documentation reflects the changes where applicable
  • changes/<pull request or issue id>-<github username>.md file added describing change
    (see changes/README.md for details)

But we have those errors

226: error: Item "str" of "Union[UUID, str]" has no attribute "hex"  [union-attr]
227: error: Item "str" of "Union[UUID, str]" has no attribute "hex"  [union-attr]
228: error: Item "str" of "Union[Path, str]" has no attribute "absolute"  [union-attr]
229: error: Item "str" of "Union[Path, str]" has no attribute "absolute"  [union-attr]
230: error: Item "str" of "Union[Path, str]" has no attribute "absolute"  [union-attr]
231: error: Item "str" of "Union[Path, str]" has no attribute "absolute"  [union-attr]
@codecov
Copy link

codecov bot commented Feb 27, 2021

Codecov Report

Merging #2420 (8af052d) into master (a8d50ae) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master     #2420   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           25        25           
  Lines         5080      5080           
  Branches      1041      1041           
=========================================
  Hits          5080      5080           
Impacted Files Coverage Δ
pydantic/types.py 100.00% <ø> (ø)
pydantic/_hypothesis_plugin.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a8d50ae...8af052d. Read the comment docs.

Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

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

LGTM, @allezxandre are you happy with this fix?

Copy link

@allezxandre allezxandre left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@samuelcolvin samuelcolvin added this to the v1.8.1 milestone Mar 2, 2021
@samuelcolvin samuelcolvin merged commit 37c37fd into pydantic:master Mar 2, 2021
@samuelcolvin
Copy link
Member

great thank you.

my_file_path: FilePath = Path(__file__)
my_file_path_str: FilePath = __file__ # type: ignore
my_dir_path: DirectoryPath = Path('.')
my_dir_path_str: DirectoryPath = '.' # type: ignore
Copy link
Member

Choose a reason for hiding this comment

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

I guess one day, when we solve koxudaxi/pydantic-pycharm-plugin#36 (comment) we could update the mypy plugin to avoid the need for all these # type: ignores

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.

UUID typing hints of Pydantic 1.8 are inaccurate
3 participants