-
Notifications
You must be signed in to change notification settings - Fork 57
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
Simplify example path manipulation with pathlib
#77
Conversation
Don't need to use both `os.path` and `pathlib.Path`
for more information, see https://pre-commit.ci
@Kilo59 Did you ever get a chance to double check that? |
@denimalpaca |
@denimalpaca But given that it's so recent it might be better to make this example work on earlier releases. |
Happy to review and merge when you make that change! |
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.
Let me know when that string call is added and I'm happy to approve!
|
||
ge_root_dir = os.path.join(base_path, "include", "great_expectations") | ||
ge_root_dir = base_path / "include" / "great_expectations" |
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.
Not entirely sure how base_path works, but are there not +'s missing here?
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.
No. The /
operator can be used to join paths.
https://docs.python.org/3/library/pathlib.html#operators
So the following will all produce the same path object. As long as the first item is a Path
object.
ge_root_dir = base_path / "include" / "great_expectations"
ge_root_dir = base_path.joinpath("include" , "great_expectations")
ge_root_dir = Path(base_path, "include" , "great_expectations")
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.
@denimalpaca updated.
Also here's another good article explaining pathlib
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.
Thanks for the links, looking into that.
Don't need to use both
os.path
andpathlib.Path
https://treyhunner.com/2019/01/no-really-pathlib-is-great/
I need to double check that
great_expectation
data_context_root_dir
actually can take apathlib.Path
object.If it doesn't it definitely should 😄 .