Skip to content

Fix CloudPathMeta.__call__ return type (#330) #336

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

Merged
merged 1 commit into from
Jun 5, 2023
Merged

Conversation

pjbull
Copy link
Member

@pjbull pjbull commented Jun 5, 2023

  • Fix CloudPathMeta.call return type

Since pyright==1.1.307, instances of the subclasses of CloudPath stopped being recognized as instances of their own class; a possible fix is to type hint CloudPathMeta.call, but it creates a host of mypy errors

  • Refactor CloudPathMeta.call

Fix mypy errors by making use of object.new and type assertions

  • Add type ignore on CloudPathMeta.call return

Incompatible return value type (got "CloudPath", expected "CloudPathT"); not a clear fix here without a more general refactor

  • Refactor CloudPathMeta.call signature to use overload

Also make issubclass(cls, CloudPath) explicit by raising TypeError

  • Run black

  • Change back init to use Self type

For some reason this leads to mypy type-var errors in the meta call (probably erroneous)

* Fix CloudPathMeta.__call__ return type

Since pyright==1.1.307, instances of the subclasses of CloudPath stopped being recognized as instances of their own class; a possible fix is to type hint CloudPathMeta.__call__, but it creates a host of mypy errors

* Refactor CloudPathMeta.__call__

Fix mypy errors by making use of object.__new__ and type assertions

* Add type ignore on CloudPathMeta.__call__ return

Incompatible return value type (got "CloudPath", expected "CloudPathT"); not a clear fix here without a more general refactor

* Refactor CloudPathMeta.__call__ signature to use overload

Also make issubclass(cls, CloudPath) explicit by raising TypeError

* Run black

* Change back __init__ to use Self type

For some reason this leads to mypy type-var errors in the meta __call__ (probably erroneous)
@github-actions
Copy link
Contributor

github-actions bot commented Jun 5, 2023

@github-actions github-actions bot temporarily deployed to pull request June 5, 2023 17:56 Inactive
@codecov
Copy link

codecov bot commented Jun 5, 2023

Codecov Report

Merging #336 (90add39) into master (6e0dafd) will decrease coverage by 0.6%.
The diff coverage is 84.2%.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #336     +/-   ##
========================================
- Coverage    94.5%   93.9%   -0.6%     
========================================
  Files          22      22             
  Lines        1466    1473      +7     
========================================
- Hits         1386    1384      -2     
- Misses         80      89      +9     
Impacted Files Coverage Δ
cloudpathlib/cloudpath.py 92.4% <84.2%> (-0.9%) ⬇️

... and 2 files with indirect coverage changes

@pjbull pjbull merged commit 4211d49 into master Jun 5, 2023
@pjbull
Copy link
Member Author

pjbull commented Jun 5, 2023

Thanks @ringohoffman!

@pjbull pjbull deleted the 330-local-tests branch June 5, 2023 18:31
msmitherdc pushed a commit to CRREL/cloudpathlib that referenced this pull request Feb 22, 2025
…aorg#336)

* Fix CloudPathMeta.__call__ return type

Since pyright==1.1.307, instances of the subclasses of CloudPath stopped being recognized as instances of their own class; a possible fix is to type hint CloudPathMeta.__call__, but it creates a host of mypy errors

* Refactor CloudPathMeta.__call__

Fix mypy errors by making use of object.__new__ and type assertions

* Add type ignore on CloudPathMeta.__call__ return

Incompatible return value type (got "CloudPath", expected "CloudPathT"); not a clear fix here without a more general refactor

* Refactor CloudPathMeta.__call__ signature to use overload

Also make issubclass(cls, CloudPath) explicit by raising TypeError

* Run black

* Change back __init__ to use Self type

For some reason this leads to mypy type-var errors in the meta __call__ (probably erroneous)

Co-authored-by: Matthew Hoffman <[email protected]>
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.

2 participants