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

Exceptions #131

Merged
merged 12 commits into from
Mar 8, 2021
Merged

Exceptions #131

merged 12 commits into from
Mar 8, 2021

Conversation

jayqi
Copy link
Member

@jayqi jayqi commented Mar 7, 2021

  • Exceptions:
    • Changed all custom cloudpathlib exceptions to be located in new cloudpathlib.exceptions module.
    • Changed all custom cloudpathlib exceptions to subclass from new base CloudPathException. This allows for easy catching of any custom exception from cloudpathlib.
    • Changed all custom exceptions names to end with Error as recommended by PEP 8.
    • Changed various functions to throw new CloudPathFileExistsError, CloudPathIsADirectoryError or CloudPathNotADirectoryError exceptions instead of a generic ValueError.
    • Removed exception exports from the root cloudpathlib package namespace. Import from cloudpathlib.exceptions instead if needed.
  • Fixed AzureBlobClient instantiation to throw new error MissingCredentialsError when no credentials are provided, instead of AttributeError. LocalAzureBlobClient changed to throw error under same conditions accordingly.
  • Fixed GSClient to instantiate as anonymous with public access only when instantiated with no credentials, instead of erroring.

Some additional testing updates:

  • Change conftest.py only run load_dotenv if USE_LIVE_CLOUD is set to 1. This was fooling my testing because an unset env var was present in my .env file.
  • Tests for specific cloud provider implementations have been parametrized to also test their cloudpathlib.local equivalents.

@jayqi jayqi requested a review from pjbull March 7, 2021 07:13
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2021

@codecov
Copy link

codecov bot commented Mar 8, 2021

Codecov Report

Merging #131 (da24f8c) into master (3d6dc72) will increase coverage by 1.3%.
The diff coverage is 85.9%.

@@           Coverage Diff            @@
##           master    #131     +/-   ##
========================================
+ Coverage    92.2%   93.5%   +1.3%     
========================================
  Files          20      21      +1     
  Lines        1098    1119     +21     
========================================
+ Hits         1013    1047     +34     
+ Misses         85      72     -13     
Impacted Files Coverage Δ
cloudpathlib/__init__.py 100.0% <ø> (ø)
cloudpathlib/cloudpath.py 90.6% <44.4%> (-0.5%) ⬇️
cloudpathlib/anypath.py 100.0% <100.0%> (ø)
cloudpathlib/azure/azblobclient.py 94.6% <100.0%> (+1.2%) ⬆️
cloudpathlib/azure/azblobpath.py 92.4% <100.0%> (ø)
cloudpathlib/exceptions.py 100.0% <100.0%> (ø)
cloudpathlib/gs/gsclient.py 91.8% <100.0%> (+0.1%) ⬆️
cloudpathlib/gs/gspath.py 93.8% <100.0%> (ø)
cloudpathlib/local/implementations/azure.py 97.5% <100.0%> (+12.6%) ⬆️
cloudpathlib/local/localpath.py 94.4% <100.0%> (ø)
... and 6 more

@@ -29,7 +29,8 @@
from .mock_clients.mock_s3 import mocked_session_class_factory


load_dotenv(find_dotenv())
if os.getenv("USE_LIVE_CLOUD") == "1":
load_dotenv(find_dotenv())
Copy link
Member Author

Choose a reason for hiding this comment

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

This had fooled my local testing by loading environment variables when I wasn't expecting them for the mocked tests.

@jayqi
Copy link
Member Author

jayqi commented Mar 8, 2021

Ended up doing more on fixing tests than I expected, but this is actually ready now @pjbull

Copy link
Member

@pjbull pjbull left a comment

Choose a reason for hiding this comment

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

This looks good to me, thanks for digging in and making this neat and tidy. Loving the readable, standardized exceptions

@pjbull pjbull merged commit 80441b3 into master Mar 8, 2021
@pjbull pjbull deleted the exceptions branch March 8, 2021 05:11
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