eschnett / ASDF.jl

A Julia implementation of the Advanced Scientific Data Format (ASDF)
MIT License
16 stars 5 forks source link

Type piracy? #2

Open giordano opened 5 years ago

giordano commented 5 years ago

Aren't

E.g.

julia> VersionNumber(Dict("major" => 1, "minor" => 2, "patch" => 3, "prerelease" => nothing, "build" => nothing))
ERROR: MethodError: no method matching VersionNumber(::Dict{String,Union{Nothing, Int64}})
Closest candidates are:
  VersionNumber(::UInt32, ::UInt32, ::UInt32, ::Tuple{Vararg{Union{UInt64, String},N} where N}, ::Tuple{Vararg{Union{UInt64, String},N} where N}) at version.jl:33
  VersionNumber(::Integer) at version.jl:61
  VersionNumber(::Integer, ::Integer) at version.jl:61
  ...
Stacktrace:
 [1] top-level scope at none:0

julia> using ASDF

julia> VersionNumber(Dict("major" => 1, "minor" => 2, "patch" => 3, "prerelease" => nothing, "build" => nothing))
v"1.2.3"
eschnett commented 5 years ago

Yes they are...

I assume ASDF should wrap the items it returns into new types. When ASDF writes, it already uses its own types, but when it reads, it directly returns what PyCall produces. It should convert (wrap) these into respective ASDF types.