53. Dope Python Tools - Darlin from Mighty.com Guest Stars!

March 13, 2018

On today's show’s we talk about a few great tools that you can use with Python. We are joined by Darlin Alberto from Mighty.com to help us unpack some of these tools and break down what’s good and what’s not. We look through a list of current tools and compare and critique their utility for your listening pleasure. We also chat about the latest update to version 3.0 from 2.7 and how this might affect compatibility and unity among developers. We are sadly missing William Jeffries today but we hope we can make up for this with our great guest and discussion. Without further ado let’s get down to business! Listen in to hear all about it!

Key Points From This Episode:

  • An introduction to the newest developments in Python and compatibility.
  • Darlin’s job and how he uses Python.
  • What differentiates Python 3 and how its tools might overlap into other platforms.
  • The update from version 2 and how long with change will take for most developers.
  • Darlin’s thoughts on GraphQL and how it measures up.
  • Other useful tools as your app grows and changes.
  • Using isort to clean up and find problems automatically
  • And much more!

Transcript for Episode 53Dope Python Tools - Darlin from Mighty.com Guest Stars!

[0:00:01.6] MN: Hello and welcome to The Rabbit Hole, the definitive developers podcast in fantabulous Chelsea, Manhattan. I’m your host, Michael Nunez. Our co-host today —

[0:00:10.4] DA: Dave Anderson.

[0:00:11.6] MN: And today, we’ll be talking about some dope Python tools, tools you should be using in your code base.

[0:00:16.6] DA: And, if you’re not using Python then you should just start today.

[0:00:20.0] MN: Right now.

[0:00:20.7] DA: Rewrite your entire application, all of your side projects in Python.

[0:00:25.1] MN: Yes.

[0:00:25.2] DA: That’s great.

[0:00:27.0] MN: Yes, today we’ll be talking about some Python tools including API Star, Python-Dev, and CI Tools and GraphQL. There are some more GraphQL conversations that will happen.

[0:00:37.1] DA: You know, I can't stop talking about it, I’m sure I don't.

[0:00:40.7] MN: But, before we continue we have a special guest today Darlin Alberto. How is it going Darlin?

[0:00:45.0] DAL: It’s great.

[0:00:46.0] DA: Darlin could you give us a quick intro of yourself.

[0:00:49.7] DAL: Yeah, under directive engineering at Mighty.com I’ve been programming for a spell and I’m happy to be here. Python and tools are things I like so this is special place for me tonight.

[0:01:03.5] DA: You happen to be sitting at the right recording studio.

[0:01:05.3] DAL: Yes.

[0:01:05.3] DA: Let’s talk about tools. What are tools?

[0:01:07.1] MN: Seems like, what are you talking about Python?

[0:01:12.2] DA: Tools. Let me in. Awesome, do you guys have anything in mind you want to start with a particular tool?

[0:01:16.6] DA: Yeah, I’m in – I when we are turning before like API Star like this sounded super cool like I had not heard about this and I was very excited to hear more about it.

[0:01:129.6] DAL: Yet, I have not used it in production by any means but I read the readme in the forum expert.

[0:01:33.8] MN: There you go, that's how things work and program work. Did you read the manual? Yeah, I’m an expert.

[0:01:40.8] DAL: And, it was very interesting I guess it has a little bit of pedigree comes from the core developer of Django REST Framework and I think maybe you guys are used to it before.

[0:01:50.4] DA: Yeah, yeah, I definitely used it before like I’m actually, you know, he really did a good job with that like he really put on a lot of energy in to like not just developing in this tool but like also documenting it and building the community. Yeah, like so I’m excited to hear that he's doing something else.

[0:02:06.0] DAL: Yeah, it – I think that’s exactly my – I share the same thoughts and he actually happens to be at Django Core developer.

[0:02:13.2] DA: Oh really, okay. I guess that’s how he landed the gig of being a paid contributor for –

[0:02:19.1] DAL: Right.

[0:02:19.1] DA:  - the best framework for Django.

[0:02:24.9] DAL: So, it is a new project I think he still maintaining and committed to Django REST framework but he’s also branching out and working on this new framework that is agnostic towards the underlying store and other components. Everything is pretty modular and replaceable it’s claim to fame is that it’s super productive and fast.

[0:02:47.3] DA: Yeah, and also like another thing that I saw that seem pretty interesting was that its Python 3 only, right?

[0:02:55.0] DAL: It’s a brand new world, right?

[0:02:56.4] MN: What is this? Is this finally happening like –

[0:02:58.3] DAL: To 10 or 20 years or so.

[0:03:02.5] DA: Right, we’re not supporting and also like Django as well like also stop supporting -

[0:03:08.9] DAL: Yeah, this is, I’m so happy to start using Python in production 3 or 4 years ago and it’s happy, I’m happy to not be the black sheep of the community in feeling like there’s a small minority of Python 3 users.

[0:03:22.5] DA: Yeah, I know, I just felt like, kind of like, this is a controversial opinion.

[0:03:26.9] DAL: Yeah.

[0:03:26.9] MN: I don’t care really care too much of the change of strings.

[0:03:31.5] DAL: But, that’s what it’s all about that you code strings.

[0:03:32.9] DA: Yeah, cool so you’re saying that this is not only exclusively in Python 3 which is cool but it’s also like very performant and very nice to use as a developer as well.

[0:03:45.3] DAL: Yeah, so it fully embraces type and Python 3 which means you got a little bit of better developer tools like when you’re developing you have information about the request and everything you’re getting. I believe that the core design is that he just had to actually optimize their performance so API Star [inaudible] claims to be the fastest Ruby, Python or Go what framework which is pretty impressive.

[0:04:14.2] DA: Yeah, I guess want to keep an eye on it like and look for some blog posts where people like refute this claim.

[0:04:22.8] MN: Yes, it was all the ruse.

[0:04:25.6] DA: How long does API Star been I think like out in production that people been using it?

[0:04:29.9] DAL: I don’t know if it’s out in production in any serious application but  I know that it’s been open source for about a year and a half or so.

[0:04:36.8] MN: So, this is like fairly new in the field.

[0:04:38.8] DAL: Yes, cutting edge stuff.

[0:04:42.1] DA: Oh man, yeah, so I’m curious about like the this hyphens, that like does that apply to the data that you get out of the API as well like is that typed in some kind of schema?

[0:04:52.2] DAL: I believe so and I think that they when you’re modeling your API they actually require you to specify a schema for the data that you’re you expected and the data that you get out which is little bit different than what you would get in a normal dynamic language of what framework.

[0:05:09.0] DA: This is interesting for me being a developer who was like working with Java for so long and SOAP which I think that you’ve lived this as well. Well I guess okay everything is strongly typed.

[0:05:21.8] DAL: Oh yeah.

[0:05:22.6] DA: We have SOAP and there’s like a contract and agreement like for all of our end points and they were like, oh no no’s, is Ruby, it’s like REST like there is no contract like it’s, you know, verbs -

[0:05:33.8] MN: Wild wild west. What do you mean? Where is the contract?

[0:05:39.9] DA: Now we are going back now we got schema’s which is cool. I’m welcoming it back in my life and also like static typing on Python as well and I believe Ruby is also working on it for Ruby 3.0 like -

[0:05:55.2] DAL: It’s a big thing in the PHP 2 hack of Facebook fame I guess and type script is huge in the JavaScript world now well.

[0:06:05.6] DA: Yeah, that’s true, Flow as well.

[0:06:07.4] MN: Yeah, Flow is the thing I’m currently using and seems to be just it’s pretty cool to have just like copulation errors when you are writing code as like the thing, kind of, like how when you see Linter but having things strongly typed. I kind of missed it like I’ve been dealing with like React, JavaScript, for some time now and when I look at JavaScript Flow just having things typed – statically typed, oh no, that supposed to return a string or no. Just like, we woah, undefined, oh no, I got to do something about that. And then, you know exactly what to do. So, as Python 3 like moving towards the statically typed language framework or –

[0:06:44.7] DA: What is it like three, three five, type annotations?

[0:06:49.0] MN: And you – and you’re forced to do that or no?

[0:06:51.1] DA: It’s, well, I guess three five introduce annotations and then it’s up to you to do what you want to do with it.

[0:06:58.1] DAL: It’s – I think it’s in the same vein as type script and other I guess gradual typing systems so it opt in and they’re supposed to be really great for actually using in system code base.

[0:07:12.1] DA: I see, so you can interchangeably use both at the same time both type script - you can use both the statically typed version of Python and not have a statically typed at the same time.

[0:07:21.7] DAL: Yes, exactly and –

[0:07:22.8] DA: Just implicit that, as anything.

[0:07:27.4] DAL: Right so, it’s pretty exciting, very different so, you know, to be fair I think it’s not fully static typing but I think it – it’s kind of exciting you get the best of both worlds, in theory.

[0:07:39.8] DA: Yeah, it’s something that I think it’s interesting with Python static typing is you strip it all out because you’re compiling down to like you’re not writing not really a JavaScript like you combine down to JavaScript that doesn’t have it but in Python I guess the interpreters ignores it one time.

[0:07:57.8] DAL: Yeah, and I think that there are actually some tools in the community that actually enforce type PINS at runtime as you can imagine there’s performance overhead of doing that for interpretive language but it is an option and it the information fully there.

[0:08:12.3] DA: Yeah, I guess it would be a nice thing to do in like in a staging environment or something like you don’t mind it was little bit slower and you do want to see it burn. Cool, yeah.

I found myself like looking at an open source project through the day and trying to graph the code and really PINGING for static types like if I just had a static type then I would know what this thing was.

[0:08:36.2] DAL: You can navigate the web that is this code base.

[0:08:38.8] DA: Yeah exactly, and as I hope when did this happen? It’s pretty great like especially when you’re trying to learn a bit of some code.

[0:08:46.6] DAL: Exactly, especially if your app as your app grows and hopefully becomes successful it’s nice to be able to say, “I know exactly what’s happening here.”

[0:08:54.6] MN: Yeah, I have a question so the talking about the death of Python 2, how long do you think it would take for the community to have more of the usage of Python 3 over 2 at this point in time? Like, does this app just like average code base update often to get like the latest language optimization or is it  often times are like a particular piece of production code would stay at legacy in Python.

[0:09:24.7] DAL: I think it’s, from what I’ve seen it’s interesting because there – when Python 3 was introduced, 2 was almost frozen in time and so, there are all these app there are all these applications that are perpetually stuck on 2,7, but on the flip side if you’re using Python 3 when this release has come out people upgrade regularly. I say, the transition between two, seven, and three I think that’s to be determined –

[0:09:52.2] DA: Yeah, it seems like a lot of times it’s, kind of, like you have those 2,7 app and it may not have task coverage. You may not feel confident in like what those task are telling you and then you just have to rewrite it all over again or like go through a process I remember seeing some blog post about these folks who did a big transition of  2,7 Django to three in modern Django and it took them several months.

[0:10:21.4] DAL: But, I think things where looking up I think Django 2.0 now officially deprecated support for Python 2 and I think there is critical massive, you know, top libraries that have Python 3 support. So my hope is that the community can unify once more behind a single, I guess, version of the language.

[0:10:41.7] DA: Yeah, it’s like the PHP model it’s never really gone away entirely so like we’re trying before about some other tools. What else might be useful like as your app is growing, like?

[0:10:51.2] DAL: So, I think one tool so the type in to your I guess a speck but we one tool I’ve used is MiPi to actually check these type PINS at, sort of, during CI and that’s a nice reassurance of an additional check, an additional safety net.

[0:11:10.2] DA: So, you put that in to your bill process and –

[0:11:12.3] DAL: Exactly, yeah, before anything that merge the type information should match what you said it did.

[0:11:19.7] DA: What about Isort?

[0:11:21.7] D: isort is also great I think that I think it’s in the different vain I think it doesn’t really enforce any extra confidence but it’s nice to, sort of, have tools that remove type tight eye shutting.

[0:11:34.9] DA: Yeah, what is the tool exactly?

[0:11:36.5] DAL: isort given the configuration will automatically sort your Python imports and –

[0:11:41.1] DA: Each of the files.

[0:11:42.0] DAL: Exactly, and it’s great and it seems like a weird thing. I think that this is a good tool where if you’re not using Python you should try to find an equivalent in your language and or implement your own because it’s pretty nice to have alphabetized, separated, and normalize import especially an application become larger and larger.

[0:12:02.0] MN: You don’t have a person in your team who just shouts at you it’s not a good time. 

[00:12:10] DA: I – you know, I was thinking about that and like I’ve totally like, and most of the project I’ve had there’s always been just a dude. There are, you know, a programmer who has opinions and I’m just like, “Sure, yeah, let’s do that,” but the current project I don’t think anyone has strong opinions so if I’m I feeling like a drift. I need to find this tool.

[0:12:30.5] DAL: I used to be that guy and then I found this tool and I don’t need to be that guy anymore.

[0:12:34.5] DA: Exactly, now no one has to be that guy or girl because you download isort and you put it isort, right?

[0:12:40.3] DAL: Yeah.

[0:12:40.3] DA: Yeah, you download isort and it was for you.

[0:12:44.4] DAL: Let us not save, right everything is all that.

[0:12:47.7] DA: That’s pretty on those piece and it’s like it’s not me it’s the computer and like I’m your friend.

[0:12:52.4] DAL: And, these are community standards and this is what we believe in.

[0:12:57.1] MN: Right.

[0:12:57.1] DA: Yeah, are you part of the community?

[0:13:01.4] DAL: No, we all are part of the community. Let’s all, as one, sort alphabetized packages.

[0:13:09.5] DA: Yeah, but I like there are a lot of edge cases though because I tried just doing it manually with our React app and like once you have like more than 10 then it gets really confusing and also sounds it’s like I’m so more on the thing I’m importing from or the thing that I’m, like the fireworks from or the path that it’s in like what is it mean to really sort something? Get existential about it and I don’t know that’s the thing that like a Linter and like, you know, that kind of thing.

[0:13:40.0] MN: Let the computer figure it out some of the do they agree?

[0:13:42.8] DA: Just do a fixed flag on that command line tool and let it, let it –

[0:13:47.4] DAL: What’s great about isort is that you don’t need to do anything so I actually don’t even think about sorting anymore just let the tool take care of it. So, there’s this stuff new found freedom that you have letting the computer do the tedious and boring things.

[0:14:02.7] DA: Yeah, like there is so much more time in your life. They don’t know your sorting imports on that.

[0:14:07.5] DAL: I’m saying 30 second a day I think at least.

[0:14:11.9] DA: At least, I mean hey, if you’re using Vim then it’s compound interest.

[0:14:15.6] DAL: Exactly.

[0:14:17.9] MN: Yeah, I mean that definitely sounds like a package that will definitely clean up the code base and unify the entire code base that people are using in Python.

[0:14:30.9] DA: Another tool I like saw pretty recently two months ago. That I got excited was  like, Pippin there was so many like these brit like environment management tools and after like taking a brief foray to Ruby Land where it’s just like just use Bundler and Bundler does all the things for you. It was nice to have that and see that like, kind of, philosophy applied to Python.

[0:14:51.0] DAL: Right, that normalization in that like you don’t think about all the ways to package and manage dependencies in Python.

[00:15:00] DA: Yeah, activate this or, you know have my like virtual end wrapper and my regular virtual - just like burritos of requirements

[0:15:12.9] MN: Wraps on wraps on wraps.

[00:15:14] DAL: Russian dolls situation right.

[00:15:17] MN: I mean there's always talk, the new hot wave or the tool you all should be using which is GraphQL, or GraphQL, GraphiQL we had a whole episode on GraphQL but love to bring it out in terms of white back end and how that plays with Python. What are your thoughts on that Darlin?

[00:15:37] DAL: I haven't used in production myself but I'm impressed with what it promises and also, in particular the Python to port because you know it came out of - I think the tooling is strongest in Javascript that's the ecosystem that is born from.

[00:15:55] DA: Yeah, definitely.

[00:15:54] DAL: So, I was impressed. I think Dave you have some experience with it, in real life.

[00:16:00] DA: Yeah, yeah. So like, my experience was in the past then with Ruby and most recently with Python a little bit, but mostly in the front end like consuming it through like Javascript and Apollo. Yeah, the tooling is pretty great for Javascript from the front end but in other places it lags a bit but I spent sometime this weekend like diving it a little bit more with Graphine]  and the Django-extension for Graphine and made like a little application, I really can it was pretty fun and yeah, it's pretty nice it's kind of intuitive. It follows a similar pattern to Django with meta classes and all that craziness which I spend some time like routing around in the library code it's just meta programming all over the place which you know that's great but - 

[00:16:51] DAL: That's the only way if you really want to get anything done.

[00:16:55] DA: I need to write code that writes code for my code.

[00:16:59] DAL: Yeah. What's been your experience with GraphQL for writes and I think they call them mutations or something. That part to me is a little bit not as intuitive as the rest of it, you know.

[00:17:11] DA: Yeah, yeah, it does seem a little bit strange, and the name mutations sounds very scary too. It's like Teenage Mutant Ninja Turtles in a situations like stay away from that.

[00:17:26] DAL: Doesn't it that get you excited for it though? You're mutating the data.

[00:17:31] DA: I guess it should give me more excited maybe that's why I need to think about it. It's like this would give me powers.

But, yeah, so mutations are a little bit weird but like actually it kind of make sense in the end because like you can think of it as you have like some inputs which you’re passing in an object like so you're really like you know at a post and then you have an object that has all of the post stuff and then after that input you have a query so it's actually secretly a query as well and you just defined a query using a GraphQL query language and you get back that data to your client and if you're using something nice like Apollo and you have global unique IDs for all of the different entities they're getting back then it can denormalize that update the cache and everything is magic.

If you don't have the setup right then everything is not magic and you just have to deal with it.

[00:18:30] DAL: It certainly reminds me of a non-Python tool that might be interesting, I've been interested in trying now called Postgres which is a I believe the Haskell application that introspect a Postgres database and builds a restful API for you.

[00:18:48] DA: Oh, yeah, yeah I've heard about this.

[00:18:48] DAL: And I think there's now I don't know if Postgres is the one but there is now one that does it for GraphQL which seems pretty exciting to have, and terrifying but -

[00:19:00] DA: Just let everything fly. Yeah, there is since it's statically typed like you can kind of adopt it in to anything like - I've seen adapters for JSON API and Open data and like Swagger like all the things basically. GRPC and you're just going to be like, “Okay since this is statically typed and GraphQL statically typed then you can just be a part of my API too and I just take it in.

[00:19:28] DAL: So, I didn't realize that static typing was a big part of GraphQL that's -

[00:19:33] DA: Yeah, you also define schemas in GraphQL so that's why I was really excited when I was reading this. I was like is this also GraphQL? Like, everything is GraphQL, I don't know.

[00:19:43] MN: GraphQL all the things.

[00:19:45] DA: Yeah, but it's pretty fun. I've enjoyed that. I definitely recommend like diving in especially like for using it with the REACT community, the community goes pretty robust there.

[00:19:59] DAL: So, crazy idea would you maintain an application that had a rest for API and a GraphQL API says -

[00:20:07] DA: Yeah, man sure.

[00:20:08] DAL: It's unpure and -

[00:20:10] DA: Yeah, no actually I think that totally makes sense that there are different applications for both and, yeah, actually you can even consume your REST API in the GraphQL API, if you wanted to do that.

Because it's like that's more like the big companies like Twitter and Yelp they're consuming micro services that feed in to this like unifying GraphQL layer for people to use exactly in a more productive way.

But then you just have to maintain the whole test suddenly if you have a monolith that's really not the way to go but, yeah, like there's different use cases for each for sure. You can even share some of the code in between them like the models and all that good stuff.

[00:20:55] MN: So, we're going to tie for one more dope Python tool, just one more, every developer should be using right now. Let's have the conversation for the next couple of minutes and then we'll wrap it up.

[00:21:07] DAL: So everyone should be using Flake8 if you're not you should be and it's really great I think it's one of those tools that you learn about them in one ecosystem and you can take your learning elsewhere. So I think analogous tools exist in other ecosystems yes-lint, TSLint in the Javascript ecosystem, RuboCop an editor of this -

[00:21:30] DA: RuboCop is probably the most awesome tool. No one else even tried.

[00:21:36] DAL: Yeah, it's like it's so boring.

[00:21:39] DA: I mean, he may not know the answers to those but that's fine but like do you know what Flake8 comes from like -

[00:21:44] DAL: Yes, it's actually a hybrid of two tools. Pyflakes which is super strict about linting errors and PEP 8, so PEP 8 is for those who aren't familiar like the style guide, the pseudo style guide in Python, there's actually a tool that's called PEP 8 that enforces common sense rules. So, Flake8 is kind of a hybrid thing.

[00:22:09] DA: Okay, cool and so I have used [inaudible] before do, then do you have like any special like preference for Flake8 or is it just like having that guy whose not you whose computer who tells people to write better code.

[00:22:27] DAL: That, certainly, but also I think it is good balance between the strictness of Pyflakes and the open-ended but common sense nature of Pep8. So it kinda, it’s configurable but it has good defaults and its somewhere between, where it’s not too opinionated or overly strict.

[00:22:46] DA: Okay, yeah, that's a good point I guess like with any kind of linter like we want to start in a good place or have like a good like community of defaults to pull from like for the ESLint we're using, the AirBnB standard and just plug that in and get it in there.

[00:23:05] DAL: Not there.

[00:23:04] MN: The plugin.

[00:23:06] DA: I would say.

[00:23:07] DA: [inaudible + 00:23:08] some code bases in, that's some interesting results.

[00:23:08] DAL: Oh yeah, I mean the best part is you save it and it fixes it up for you, I mean we're talking about that before in the SFfix.

[00:23:16] DA: Oh, yeah that's SFfix, to fix it up, throw it over the wall.

[00:23:19] DAL: But if I'm not mistaken not all rules in ESLint are fixable, automatically fixable.

[00:23:25] MN: Oh, yeah I mean you would have, you would have to then dive whatever is not auto-fixable but I mean ESLint goes well with a lot of editors where the minute you open a file, it's like a thousand things on the slate to fix them now and you go and you just rip right through them one at a time. Majority of the things you can fix at which -

[00:23:46] DAL: I will say it really sucks integrating one of these tools or any linting tool in a legacy code base.

[00:23:53] MN: You just rewrite the Python, I think we established that you just rewrite it all in Python and you’re -

[00:23:59] DAL: And start with Flake8.

[00:23:59] DA: And start with Flake8 and then boom. Day one, you're doing it right.

[00:24:05] MN: You want to do it right from the start get your self these tools. These dope Python tools are built so that the developers in the community like ourselves can ship out amazing, amazing well-organized, alphabetized, linted code. That makes sense, that makes common sense, for everyone.

[00:24:26] DA: Cool.

[00:24:26] MN: Darlin thanks for coming on down, greatly appreciate for having you here, where can people reach you?

[00:24:32] D: Well, thank you for having me, I think probably the best place is Github weirdly enough, so my handles ‘dalberto’ and I love learning new things and being how I'm wrong.

[00:24:46] MN: Yeah, you get a lot of that in Github. Yeah, great Dave it's always great having you around, thank you so much for again giving us the wonderful knowledge of GraphQL.

[00:24:58] DA: Speaking the good word of GraphQL.

[00:25:00] MN: Exactly, yeah, Darling thanks again for coming on down, I greatly appreciate you coming on down, always welcome.

[00:25:06] DA: Thank you.

[00:25:07] MN: I'm Michael Nunez, feel free to hit us up at twitter.com/radiofreerabbit and if you haven't like, subscribe and give us a five star review on iTunes. This is The Rabbit Hole, we'll see you next time.

Links and Resources:

The Rabbit Hole on Twitter

Darlin Alberto


API Star


Django REST Framework

Django Core