-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
Fix Compat on master by updating walkdir #307
Conversation
We shouldn't deprecate |
I have an alternative approach here: https://github.com/TotalVerb/Compat.jl/commit/8f6d272edd06f845fbab66f9d138027fa3622186 This will deprecate |
I'm not completely sure about what is the right solution here but |
There may be packages that still support 0.4 and 0.5, and have yet to upgrade to 0.6. Compat should not break these packages or add deprecation warnings to them until Compat drops support for those versions. (Part of a point of a stable release, like 0.4/0.5, is to not have code suddenly give deprecation warnings. Other packages do deprecate things all the time, but Compat should be extra careful.) That this feature is deprecated in Julia 0.6 means that we should deprecate it for Julia 0.6, but not 0.5 or earlier. |
src/Compat.jl
Outdated
if VERSION < v"0.5.0-dev+961" | ||
export walkdir | ||
|
||
if VERSION < v"0.6.0-dev.2043" | ||
function walkdir(root; topdown=true, follow_symlinks=false, onerror=throw) |
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.
should document that walkdir
should be used as Compat.walkdir
on 0.5
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 doesn't the base walkdir work on 0.5?
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.
you can't take!
from a Task
, so the two walkdirs are not compatible
src/Compat.jl
Outdated
@@ -152,21 +152,21 @@ elseif VERSION < v"0.4.0-dev+6987" | |||
export pipeline | |||
end | |||
|
|||
if VERSION < v"0.5.0-dev+961" |
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.
should still export walkdir on 0.4
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.
isn't the semantic change breaking for anyone using this on 0.4?
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.
Yes, any code using consume(walkdir(...))
will break. I don't know how to address this without keeping around two versions of walkdir
.
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.
export an old version on 0.4, have a non exported new version
It would be breaking to unexport |
I think it is flawed to support the syntax of several versions of Julia at the same time and not only the latest version but I guess we are already doing that so I'll remove the part of this PR that touches |
src/Compat.jl
Outdated
dirs = Array(eltype(content), 0) | ||
files = Array(eltype(content), 0) | ||
dirs = Array{eltype(content)}(0) | ||
files = Array{eltype(content)}(0) |
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.
Vector
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.
This code is copied from Base; I don't think Compat should deviate from it.
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.
it should be Vector in base then
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.
The Array{T}(0)
pattern is used very frequently in Base. Should that be changed in Base, then it can be changed here too.
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.
it should, and has been in many places - it's easier on the compiler to call the constructor of a fully parameterized type instead of having to infer the dimensionality
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.
I couldn't find a Base issue so opened JuliaLang/julia#20114.
test/runtests.jl
Outdated
@test trunc(Int, [1 1]) == [1 1] | ||
@test trunc(Int, [1.1 1.1]) == [1 1] | ||
@test trunc(Int, fill(1.1, 2, 3, 4)) == fill(1, 2, 3, 4) | ||
if VERSION < v"0.6.0-" |
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.
be more specific, and anything called on scalars should run everywhere. or better, do @compat
and dot syntax everywhere
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.
Dot syntax doesn't work on 0.4 and 0.5 yet for these functions, see #297.
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.
okay, then anything on scalars should run everywhere, anything vectorized on the specific julia versions where it's not deprecated
test/runtests.jl
Outdated
@@ -981,29 +983,29 @@ cd(dirwalk) do | |||
follow_symlink_vec = has_symlinks ? [true, false] : [false] | |||
has_symlinks && symlink(abspath("sub_dir2"), joinpath("sub_dir1", "link")) | |||
for follow_symlinks in follow_symlink_vec | |||
task = walkdir(".", follow_symlinks=follow_symlinks) | |||
root, dirs, files = consume(task) | |||
task = Compat.walkdir(".", follow_symlinks=follow_symlinks) |
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.
Should also rename "task", "task_error", etc to "chnl", "chnl_error" everywhere.
I've updated the PR such that it doesn't touch |
b83b3b5
to
8053b6f
Compare
I've added a fix for #315 as well. It disables the same tests as in https://github.com/JuliaLang/julia/pull/18777/files#diff-3d2d2cb368aae0105589988195f6b11aL341 . |
And multiple outstanding line comments. |
@amitmurthy I guess that |
task-channel binding is not supported on 0.5 Compat's implementation of walkdir should
I can push a commit to your branch later if you don't mind. |
README.md
Outdated
@@ -81,7 +81,7 @@ Currently, the `@compat` macro supports the following syntaxes: | |||
|
|||
* `foreach`, similar to `map` but when the return value is not needed ([#13744]) | |||
|
|||
* `walkdir`, returns an iterator that walks the directory tree of a directory ([#13707]) | |||
* `walkdir`/`Compat.walkdir`, returns an iterator that walks the directory tree of a directory. For compatibility with Julia 0.6- `Compat.walkdir` should be used and `walkdir` should be used for compatibility with the Julia 0.5. ([#13707]) |
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.
"for compatibility with Julia 0.5"
16ffa63
to
4b5e947
Compare
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.
LGTM
No longer relevant. The approach to walkdir is different now
@test trunc(Int, fill(1.1, 2, 3, 4)) == fill(1, 2, 3, 4) | ||
|
||
if VERSION < v"0.6.0-dev.1825" | ||
@test round(Int, [1, 1]) == [1, 1] |
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.
@compat round.(
?
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.
ref #297
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.
I see thanks. I don't care too strongly about these tests on 0.6, so I'm fine with this.
@@ -194,6 +194,9 @@ if VERSION < v"0.5.0-dev+961" | |||
Task(_it) | |||
end | |||
end | |||
if VERSION < v"0.6.0-dev.2043" | |||
Base.take!(t::Task) = consume(t) |
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.
should be mentioned in readme
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.
It is notnow mentioned in the README.md
.
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 = now ?
Make trunc, round, floor, ceil testing more precise
Tests failing on nightly now. |
Just realized. I think the deprecations caused |
depended on the deprecation definition in Base so it is kind of broken but I have left the definition to minimize the effects of this PR.
I think this is good to go. @andreasnoack do the honors? |
* Remove `take!(::Task)` definition for Julia versions prior to 0.6 Was added in #307. * Remove `redirect_std*(f, stream)` definitions for Julia prior to v0.6 Were added in #275. * Remove at-__DIR__ macro definition for Julia versions prior to 0.6 Was added in #281. * Remove `broadcast` definition for equal-length tuples Was added in #324 and #328 * Remove definitions of `unsafe_get` and `isnull` fallsback Were added in #287. * Remove defintions of `xor` and `⊻` Were added in #289. * Definitions of `numerator` and `denominator` Were added in #290. * Remove defintion of `iszero` Was added in #305. * Remove definition of `>:` Was added in #336 * Remove definition of `take!(::Base.AbstractIOBuffer)` Was added in #290. * Remove definiton of `.&` and `.|` Were added in #306. * Remove definition of `Compat.isapprox` Was added in #309.
Since
walkdir
returns aTask
in 0.5 and aChannel
in 0.6 the implementation in Compat would need to be updated. For now, I've done this by not exporting theCompat
version such that you'd have to useCompat.walkdir
instead of justwalkdir
.promote_eltype_op
is now deprecated on master so I've also deprecated theCompat
version.Testing of vectorized
round
,ceil
,floor
, andtrunc
is disabled on 0.6 since the dot syntax should be used.Some minor syntax deprecations.