oto icon indicating copy to clipboard operation
oto copied to clipboard

Add python client generation to /example

Open sethcenterbar opened this issue 4 years ago • 5 comments

1. Add python client to /example image

2. [WIP] Generate python classes from def.Objects Requires:

  • (Probably) Adding a Python mapping for (*Parser).parseFieldType ✅
  • Creating classes for def.Objects ✅
  • Create Constructor from object.Fields ✅
  • Adding type hints via field.type 🚧
  • ???

sethcenterbar avatar Nov 21 '20 17:11 sethcenterbar

This statement seems pretty generic. I'm throwing in int for now, but should we look at breaking this into a few different cases (int, double, float)?

// (*Parser).parseFieldType()
                ...
		case "int", "int16", "int32", "int64",
			"uint", "uint16", "uint32", "uint64",
			"float32", "float64":
			ftype.JSType = "number"
			ftype.SwiftType = "Double"
			ftype.PythonType = "int"
		}

sethcenterbar avatar Nov 21 '20 18:11 sethcenterbar

We may need to name the generated file differently for python, as you can't import python files with periods in the name.

for example, I cannot import the following from .client.gen import GreetRequest

but I can import from .clientgen import GreetRequest.

This is likely because it's parsing for .py.

sethcenterbar avatar Nov 21 '20 19:11 sethcenterbar

Docstring generation is coming along. It's pretty verbose, but it does make the cliengen more discoverable. image

I'm still not super happy with the ide help here, it's just not super pretty. image

sethcenterbar avatar Nov 22 '20 23:11 sethcenterbar

@sethcenterbar What was the status on this in the end? Did you get it working?

matryer avatar Mar 14 '21 12:03 matryer

Hey @matryer, I think it was working. I'm pretty sure I was looking for feedback here. Honestly, I'd have to open this back up and poke around. If you're happy with the basic implementation, I'll take some time this week to finish it up.

We may need to name the generated file differently for python, as you can't import python files with periods in the name.

for example, I cannot import the following from .client.gen import GreetRequest

but I can import from .clientgen import GreetRequest.

This is likely because it's parsing for .py.

sethcenterbar avatar Mar 16 '21 15:03 sethcenterbar