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

fixing raise-missing-from in remaining places #4255

Merged
merged 1 commit into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/prefect/engine/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ def deserialize(self, value: bytes) -> Any:
try:
# old versions of Core encoded pickles with base64
return cloudpickle.loads(base64.b64decode(value))
except Exception:
except Exception as e:
# if there's an error with the backwards-compatible step,
# reraise the original exception
raise exc
raise exc from e


class JSONSerializer(Serializer):
Expand Down
4 changes: 2 additions & 2 deletions src/prefect/tasks/airtable/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
try:
from prefect.tasks.airtable.airtable import WriteAirtableRow, ReadAirtableRow
except ImportError:
except ImportError as err:
raise ImportError(
'Using `prefect.tasks.airtable` requires Prefect to be installed with the "airtable" extra.'
)
) from err
4 changes: 2 additions & 2 deletions src/prefect/tasks/aws/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def run(
jobDefinition=job_definition,
**batch_kwargs,
)
except Exception:
raise FAIL(f"Failed to submit job '{job_name}' to AWS Batch.")
except Exception as e:
raise FAIL(f"Failed to submit job '{job_name}' to AWS Batch.") from e

if not response.get("jobId"):
raise FAIL(f"AWS Batch submit response contains no job ID: {response}")
Expand Down
8 changes: 5 additions & 3 deletions src/prefect/tasks/aws/client_waiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ def run(
try:
waiter.wait(**waiter_kwargs)
except WaiterError as e:
raise FAIL(f"AWS {client} waiter '{waiter_name}' failed with: {str(e)}")
raise FAIL(
f"AWS {client} waiter '{waiter_name}' failed with: {str(e)}"
) from e

@staticmethod
def _load_prefect_waiter(
Expand All @@ -131,7 +133,7 @@ def _load_prefect_waiter(
waiter_model = WaiterModel(json.load(handle))

return create_waiter_with_client(waiter_name, waiter_model, boto_client)
except Exception:
except Exception as err:
raise ValueError(
f"Unable to load waiter '{waiter_name}' for AWS client '{client_str}'."
)
) from err
4 changes: 2 additions & 2 deletions src/prefect/tasks/azure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
CosmosDBReadItems,
CosmosDBQueryItems,
)
except ImportError:
except ImportError as err:
raise ImportError(
'Using `prefect.tasks.azure` requires Prefect to be installed with the "azure" extra.'
)
) from err
4 changes: 2 additions & 2 deletions src/prefect/tasks/azureml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
DatastoreUpload,
)

except ImportError:
except ImportError as err:
raise ImportError(
'Using `prefect.tasks.azureml` requires Prefect to be installed with the "azure" extra.'
)
) from err
6 changes: 4 additions & 2 deletions src/prefect/tasks/dbt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@

try:
from prefect.tasks.dbt.dbt import DbtShellTask
except ImportError:
raise ImportError("Using `prefect.tasks.dbt` requires dbt to be installed.")
except ImportError as err:
raise ImportError(
"Using `prefect.tasks.dbt` requires dbt to be installed."
) from err
4 changes: 2 additions & 2 deletions src/prefect/tasks/dropbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
try:
from prefect.tasks.dropbox.dropbox import DropboxDownload
except ImportError:
except ImportErro as err:
raise ImportError(
'Using `prefect.tasks.dropbox` requires Prefect to be installed with the "dropbox" extra.'
)
) from err
2 changes: 1 addition & 1 deletion src/prefect/tasks/gcp/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def run(
except Exception as exception:
for error in load_job.errors:
self.logger(error)
raise FAIL(exception)
raise FAIL(exception) from exception
# remove unpickleable attributes
load_job._client = None
load_job._completion_lock = None
Expand Down
4 changes: 2 additions & 2 deletions src/prefect/tasks/great_expectations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
RunGreatExpectationsValidation,
RunGreatExpectationsCheckpoint,
)
except ImportError:
except ImportError as err:
raise ImportError(
'Using `prefect.tasks.great_expectations` requires Prefect to be installed with the "ge" extra.'
)
) from err
4 changes: 2 additions & 2 deletions src/prefect/tasks/gsheets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
WriteGsheetRow,
ReadGsheetRow,
)
except ImportError:
except ImportError as err:
raise ImportError(
'Using `prefect.tasks.gsheets` requires Prefect to be installed with the "gsheets" extra.'
)
) from err
4 changes: 2 additions & 2 deletions src/prefect/tasks/kubernetes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
ReadNamespacedService,
ReplaceNamespacedService,
)
except ImportError:
except ImportError as err:
raise ImportError(
'Using `prefect.tasks.kubernetes` requires Prefect to be installed with the "kubernetes" extra.'
)
) from err
4 changes: 2 additions & 2 deletions src/prefect/tasks/postgres/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
PostgresExecuteMany,
PostgresFetch,
)
except ImportError:
except ImportError as err:
raise ImportError(
'Using `prefect.tasks.postgres` requires Prefect to be installed with the "postgres" extra.'
)
) from err
4 changes: 2 additions & 2 deletions src/prefect/tasks/redis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

try:
from prefect.tasks.redis.redis_tasks import RedisSet, RedisGet, RedisExecute
except ImportError:
except ImportError as err:
raise ImportError(
'Using `prefect.tasks.redis` requires Prefect to be installed with the "redis" extra.'
)
) from err
4 changes: 2 additions & 2 deletions src/prefect/tasks/rss/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
try:
from prefect.tasks.rss.feed import ParseRSSFeed
except ImportError:
except ImportError as err:
raise ImportError(
'Using `prefect.tasks.rss` requires Prefect to be installed with the "rss" extra.'
)
) from err
4 changes: 2 additions & 2 deletions src/prefect/tasks/snowflake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

try:
from prefect.tasks.snowflake.snowflake import SnowflakeQuery
except ImportError:
except ImportError as err:
raise ImportError(
'Using `prefect.tasks.snowflake` requires Prefect to be installed with the "snowflake" extra.'
)
) from err
4 changes: 2 additions & 2 deletions src/prefect/tasks/sql_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
SqlServerExecuteMany,
SqlServerFetch,
)
except ImportError:
except ImportError as err:
raise ImportError(
'Using `prefect.tasks.sql_server` requires Prefect to be installed with the "sql_server" extra.'
)
) from err
4 changes: 2 additions & 2 deletions src/prefect/tasks/templates/jinja2.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

try:
from jinja2 import Template
except ImportError:
except ImportError as err:
raise ImportError(
"Using `prefect.tasks.templates.jinja2` requires Prefect to be installed "
"with the 'templates' extra."
)
) from err


class JinjaTemplate(Task):
Expand Down