-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[stdlib] Temporary directory #2743
base: nightly
Are you sure you want to change the base?
Conversation
1caebd2
to
786c0a0
Compare
Part of the implementation for #2018 |
301021a
to
1ceff7e
Compare
#2742 has landed internally and will be included in the next nightly. Could you please rebase after that? Also, could you please update the PR description with a summary of the contents of this patch? |
1ceff7e
to
bcfa906
Compare
+1 to rebasing and adding a nice PR description! |
suffix: String = "", | ||
prefix: String = "tmp", |
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 Python these can also be None
. Can we also use Optional[String] = None
for these?
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.
Optional[String]
does not play along nicely with StringLiteral
, that's why I used default values for these, it should be possible to allow to use None
but I think we will need 4 overloads to cover all the cases:
fn __init__(inout self, suffix: String = "", prefix: String = "tmp", ...)
fn __init__(inout self, suffix: Optional[String] = None, prefix: String = "tmp", ...)
fn __init__(inout self, suffix: String = "", prefix: Optional[String] = None, ...)
fn __init__(inout self, suffix: Optional[String] = None, prefix: Optional[String] = None, ...)
note: mkdtemp
has the same "issue"
|
||
|
||
# TODO use shutil.rmtree (or equivalent) when it exists | ||
fn _rmtree(path: String, ignore_errors: Bool = False) raises: |
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.
Can we use PathLike
for the path
argument?
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.
listdir
returns a list of strings and os.path.join
only takes String
for now, so found it easier to use a String
for now
Yes, we could avoid Strings for path definitions, but rather PathLike traits, this for cross-platform support. |
Signed-off-by: Artemio Garza Reyna <artemiogr97@gmail.com>
bcfa906
to
92369fa
Compare
Signed-off-by: Artemio Garza Reyna <artemiogr97@gmail.com>
Implementation of
TemporaryDirectory
, a wrapper aroundmkdtemp
that can be used as a context nanager.