Skip to content

Commit 4e51d12

Browse files
authored
some more minor code cleanups (#919)
1 parent 830de99 commit 4e51d12

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

docs/src/dev_reference.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,9 @@ Revise can be made to work for transpilers from non-Julia languages to Julia wit
158158
For example, if you wrote a transpiler from C to Julia, you can define a `struct CFile`
159159
which overrides enough of the common `String` methods (`abspath`,`isabspath`, `joinpath`, `normpath`,`isfile`,`findfirst`, and `String`),
160160
it will be supported by Revise if you define a method like
161-
```
161+
```julia
162162
function Revise.parse_source!(mod_exprs_sigs::Revise.ModuleExprsSigs, file::CFile, mod::Module; kwargs...)
163163
ex = # julia Expr returned from running transpiler
164164
Revise.process_source!(mod_exprs_sigs, ex, file, mod; kwargs...)
165165
end
166-
167166
```

src/callbacks.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function remove_callback(key)
109109
nothing
110110
end
111111

112-
function process_user_callbacks!(keys = user_callbacks_queue; throw=false)
112+
function process_user_callbacks!(keys = user_callbacks_queue; throw::Bool=false)
113113
try
114114
# use (a)sync so any exceptions get nicely collected into CompositeException
115115
@sync for key in keys

src/packagedef.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@eval Base.Experimental.@optlevel 1
1+
Base.Experimental.@optlevel 1
22

33
using FileWatching, REPL, UUIDs
44
using LibGit2: LibGit2
@@ -350,7 +350,7 @@ function eval_rex(rex::RelocatableExpr, exs_sigs_old::ExprsSigs, mod::Module; mo
350350
ex = rex.ex
351351
# ex is not present in old
352352
@debug "Eval" _group="Action" time=time() deltainfo=(mod, ex)
353-
sigs, includes, thunk = eval_with_signatures(mod, ex; mode=mode) # All signatures defined by `ex`
353+
sigs, includes, thunk = eval_with_signatures(mod, ex; mode) # All signatures defined by `ex`
354354
if !isexpr(thunk, :thunk)
355355
thunk = ex
356356
end
@@ -396,7 +396,7 @@ end
396396
function eval_new!(exs_sigs_new::ExprsSigs, exs_sigs_old, mod::Module; mode::Symbol=:eval)
397397
includes = Vector{Pair{Module,String}}()
398398
for rex in keys(exs_sigs_new)
399-
sigs, _includes = eval_rex(rex, exs_sigs_old, mod; mode=mode)
399+
sigs, _includes = eval_rex(rex, exs_sigs_old, mod; mode)
400400
if sigs !== nothing
401401
exs_sigs_new[rex] = sigs
402402
end
@@ -415,7 +415,7 @@ function eval_new!(mod_exs_sigs_new::ModuleExprsSigs, mod_exs_sigs_old; mode::Sy
415415
mode = getfield(mod, :__revise_mode__)::Symbol
416416
end
417417
exs_sigs_old = get(mod_exs_sigs_old, mod, empty_exs_sigs)
418-
_, _includes = eval_new!(exs_sigs_new, exs_sigs_old, mod; mode=mode)
418+
_, _includes = eval_new!(exs_sigs_new, exs_sigs_old, mod; mode)
419419
append!(includes, _includes)
420420
end
421421
return mod_exs_sigs_new, includes
@@ -467,15 +467,15 @@ end
467467
function eval_with_signatures(mod, ex::Expr; mode=:eval, kwargs...)
468468
methodinfo = CodeTrackingMethodInfo(ex)
469469
docexprs = DocExprs()
470-
_, thk = methods_by_execution!(methodinfo, docexprs, mod, ex; mode=mode, kwargs...)
470+
_, thk = methods_by_execution!(methodinfo, docexprs, mod, ex; mode, kwargs...)
471471
return methodinfo.allsigs, methodinfo.includes, thk
472472
end
473473

474474
function instantiate_sigs!(modexsigs::ModuleExprsSigs; mode=:sigs, kwargs...)
475475
for (mod, exsigs) in modexsigs
476476
for rex in keys(exsigs)
477477
is_doc_expr(rex.ex) && continue
478-
sigs, _ = eval_with_signatures(mod, rex.ex; mode=mode, kwargs...)
478+
sigs, _ = eval_with_signatures(mod, rex.ex; mode, kwargs...)
479479
exsigs[rex] = sigs
480480
end
481481
end
@@ -736,7 +736,7 @@ end
736736
If `throw` is `true`, throw any errors that occur during revision or callback;
737737
otherwise these are only logged.
738738
"""
739-
function revise(; throw=false)
739+
function revise(; throw::Bool=false)
740740
sleep(0.01) # in case the file system isn't quite done writing out the new files
741741
lock(revise_lock) do
742742
have_queue_errors = !isempty(queue_errors)
@@ -782,7 +782,7 @@ function revise(; throw=false)
782782
mode (:sigs, :eval, :evalmeth, :evalassign) || error("unsupported mode ", mode)
783783
exsold = get(fi.modexsigs, mod, empty_exs_sigs)
784784
for rex in keys(exsnew)
785-
sigs, includes = eval_rex(rex, exsold, mod; mode=mode)
785+
sigs, includes = eval_rex(rex, exsold, mod; mode)
786786
if sigs !== nothing
787787
exsnew[rex] = sigs
788788
end
@@ -836,7 +836,7 @@ function revise(; throw=false)
836836
end
837837
tracking_Main_includes[] && queue_includes(Main)
838838

839-
process_user_callbacks!(throw=throw)
839+
process_user_callbacks!(; throw)
840840
end
841841

842842
nothing
@@ -912,12 +912,12 @@ function track(mod::Module, file; mode=:sigs, kwargs...)
912912
file = abspath(file)
913913
end
914914
# Set up tracking
915-
fm = parse_source(file, mod; mode=mode)
915+
fm = parse_source(file, mod; mode)
916916
if fm !== nothing
917917
if mode === :includet
918918
mode = :sigs # we already handled evaluation in `parse_source`
919919
end
920-
instantiate_sigs!(fm; mode=mode, kwargs...)
920+
instantiate_sigs!(fm; mode, kwargs...)
921921
if !haskey(pkgdatas, id)
922922
# Wait a bit to see if `mod` gets initialized
923923
sleep(0.1)

0 commit comments

Comments
 (0)