# Required function input types in PyJulia

**URL:** <https://discourse.julialang.org/t/required-function-input-types-in-pyjulia/100580>\
**Category:** General Usage\
**Tags:** inheritance, type-stability, pyjulia\
**Created:** [June 19, 2023, 11:18pm UTC](https://discourse.julialang.org/t/required-function-input-types-in-pyjulia/100580 "2023-06-19T23:18:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lkmc](https://avatars.discourse-cdn.com/v4/letter/l/b487fb/32.png) [@lkmc](https://discourse.julialang.org/u/lkmc)\
**Post date:** [June 19, 2023, 11:18pm UTC](https://discourse.julialang.org/t/required-function-input-types-in-pyjulia/100580/1 "2023-06-19T23:18:26Z")

</div>

I have a function in Julia that is called from Python and it seems to be enforcing a particular argument type, but I’m not sure how/where because when I change the allowed argument type to what should be the correct thing (or even Any), it does not fix the problem. It’s kind of a long story, so bear with me.

Here’s the pseudo-code that used to work. I defined a new structure type in Julia, let’s call it NewType.

```julia
struct NewType
   field1::Float64
   field2::Float64
   function NewType(; field1::Float64, field2::Float64)
      new(field1, field2)
   end

```

Then I had a Julia function that used that type as an argument,

```julia
function NewFunction(arg1::NewType)
   do some stuff
   return out
end

```

Then I called this function from Python. Here are pieces of the code:

```julia
def generate_julia_obj(self):
   return NewType(field1 = field1, field2 = field2)

arg1 = self.generate_julia_obj()
out = NewFunction(arg1 = arg1)

```

This used to work, but I recently made a change that broke this. I made NewType inherit from FieldVector and now the Python function generate\_julia\_obj outputs \<class ‘list’\> instead of \<class ‘PyCall.jlwrap’\>. So I have two questions.

1. Is there a way for NewType to inherit from FieldVector that won’t change the type in Python to a list?
2. I tried changing the argument type in NewFunction to

```julia
function NewFunction(arg1::Union{NewType,Vector{Float64}})

```

(and in an attempt to get it to work I even tried changing the argument type to Any), but for some reason that didn’t help and Python still said that there was a Julia type error and that function was expecting NewType and I don’t understand what’s going on. Any ideas?
