-
Notifications
You must be signed in to change notification settings - Fork 235
chore: make _path optional and more representative #4303
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
base: main
Are you sure you want to change the base?
Conversation
4b06000
to
7caa5fa
Compare
7caa5fa
to
ac68e4c
Compare
aab1108
to
b7be02d
Compare
b7be02d
to
f25a7ee
Compare
99d0f86
to
7055cb5
Compare
- more correctly represent path being optional
7055cb5
to
98b2d25
Compare
@@ -2171,6 +2173,8 @@ def load_sql_based_model( | |||
# The name of the model will be inferred from its path relative to `models/`, if it's not explicitly specified | |||
name = meta_fields.pop("name", "") | |||
if not name and infer_names: | |||
if path is None: | |||
raise ValueError("Model must have a name", path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is the path included, given that it's None. the string message should be enough
@@ -207,6 +207,8 @@ def _convert_models( | |||
|
|||
if model.kind.is_seed: | |||
# this will produce the original seed file, eg "items.csv" | |||
if model._path is None: | |||
raise ValueError(f"Unhandled model path: {model._path}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again in these I'm confused about the inclusion of model._path in the error message when it's none
return models.Model( | ||
name=model.name, | ||
fqn=model.fqn, | ||
path=str(model._path.absolute().relative_to(context.path).as_posix()), | ||
full_path=str(model._path.absolute().as_posix()), | ||
path=str(path.absolute().relative_to(context.path).as_posix()) if path else None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in line 125 you check for none and raise so here there is no need for a check as the path should exist
At the moment, the path type is slightly confusing. Models can exist without a Path. Rather than mark the
_path
property asNone
we callPath()
which is equivalent to callingPath(".")
which is not particularly indicative it just returns your path tocwd
. Optional is a much better representation.