Bestand wählen

Python refactoring with Rope and Traad

Zitierlink des Filmsegments
Embed Code

Automatisierte Medienanalyse

Erkannte Entitäten
is going tells that refactoring which is also an entry in so please welcome Austin and thank you and I think that's right so
and again my name is also being
and I'm going to talk to you about Python refactoring with real enthralled honestly with both of those are the 2 technologies that work together and I work for a company called city north part on it as well so of this 1 but in there right a little bit about myself am originally from Austin Texas and name results some Austin from Austin what I like to show this so this this slide to give a sense of those differences in places i've lived Austin has statues of Cedar downtown obligatory garden I went to the University of Texas of commands of about 5 years ago I moved to Norway civilian they're on the west coast of our statue there are different we have 3 swords ran into the ground a little like 30 foot tall stone swords to commemorate the unification of the Georgian kingdoms and this is this a few of the most beautiful fewer the world I guaranteeing to Bangor sometime it's really wonderful on and this is something I had at the last minute I was in the head the other day and we tend to think of Python is remedies web stuff and be useful of science and engineering I saw an art exhibit this is 1 of the most famous Mondrian paintings you rendered in using Python I I saw this at the bottom of the display and I had to get a picture that you can't really read it but it's important empire in 40 inter from red import random or or so they're using now I think to generate really interesting part for premier very overpriced painting and but the Mondrian may exhibit in in The Hague is is really really worth seeing and to see some Python so sides
so what is world world is a Python library for doing python refactoring it's it's that simple that's why I kind of have the snake eating itself it's some the
Python module you can import you can have a look at your source code and it can do things like names and and pulling out of functions and all that kind of stuff that at a very high level that's all that rope is I didn't write group is something that exists independent of me and there many the people who do it with a river right because it doesn't really hard job refactoring Python despite this dynamic requires a lot of very powerful IDE oriented features like code completion of finding definitions in occurrences these things by the way which are actually
refactoring they're just things that rope is also able to do so organizing imports good refactoring looking at docstrings etc etc it's really designed to be used from IIT is not used as a model for States not wise to import robots are trying to use it yourself because there's a lot of ceremony involved in the factories you when your idea to take care of that for you and that's kind of what I'm getting to withdraw later on so what are the elements of robotic take a pretty high level view of wrote to give
you a sense of the parts of it power refactoring books and things like that I'm not gonna get into too many details of the highest level concept is the project the project is really is a directory with a bunch of stuff on language files and other the problem and the directory containing even more files and this
this is the tree of stuff that rope is going to manipulate for you when you asked to during are remaining or something along those lines so there's a project and instantiate that with directory
and that's that the base of all the things you the greater projects just like this I think that's very readable but it's that simple there that's created a project and grades file 4 units cost a bunch of stuff and it's ready to go the kind of things you can do with projects so you can walk all the resources resources or files and directories and you can get the children of resources and continue walking so here's this suggests it's important you understand a
sister show the kind of the flavor of the API it's very straightforward really easy to understand if the data under under-documented so there is a preface objects are that you can get in this thing is basically a dictionary of of keys the values and these
values are all sorts of settings related to how much stuff you keeping cash aware of I forget all the different hundreds of them this is if you look in your o project on this you'll see a doctor or a project file that is essentially reflected directly in suppressed class so this is something you can interrogate runtime if you need to if you end up doing IT embedding of some sort with with with some right I just said that of resources again those are things like files and directories and that this is a lot of what you end up doing you work with rope walking the streets and
finding specific things you wanna work with and then applying refactorings to specific resources it's not a lot of detail just something so you have a sense of how it all puts is put together what's more interesting God for my point of view esthetically and technically is how refactoring is done so you have these kinds of projects resources and so forth but how do you actually was it look like to do a refactoring thrown from the code point you the 1st thing you do is create a reading or in this case we're creating a renaming refactoring southern port of the renamed refactoring class of constructed 1 this can fail of course if arm if rope says that that's not a resource that exists or you've like you've got off the end of the file a complaint so it's possible for the construction of this to fail immediately and you can see this is only partially bound and what I mean is that we've created a renamed we told that which project work against and we're told that the resource to work against in this case a file called state that PY and we're told that the offset which I wanted you to rename but what's conspicuously missing from this report is what you want to rename it to so Detroit has this notion is partially bound incomplete refractories it's figured out if you if you then tell it to do the renaming its figure out all the places NASA touch so interesting you can use the same refactoring multiple times if you want to for some reason rename something to 6 different things so that's the 1st step in refactoring world the next thing you do is calculate the actual refactoring what you'd actually do in this case I'm changing whatever was at 42 into the word topic after if talk character doesn't ring a bell you should because it's 1 of the greatest business models in the world it's it's armed drones delivering tacos to you it's it's brilliant and hope we want these days will be a reality but uh I think he was denied by the FAA in the United States they couldn't do 1 of these days the future will arrive once you calculated changes you haven't actually done the changes you just figure out what you want to do you can print out things like the description of the change the changed resources which is an interesting bit of information if you have an idea you need a refresher frames or something like that that's a good piece of information get without actually having done the refractory also changes represents a fully balanced change that you can then execute you just say project not due changes is the refactoring calculated and and this is when things actually change on disk so that is the sort of 10 cents 2 or of having to refactoring enough In in insists on the full process here from creating a project to create a factoring cavity changes in doing the changes so really pretty straightforward is actually pretty easy on technically very difficult but that's that's extracted it to keep the technical part difficult and I have to worry about it too much right 1 important feature of fraud is on this notion of history this is the most historically accurate picture I could find on the internet itself a blank with machine gun on a bare freeing the slaves so suggest right history it keeps track of things in this history was every project has a history of list I think is what it is worth this like I forget the exact class but it manages the changes that have been made and also the changes that have been undone so if I've made a change I wanna do it I can do it but also remembers the things up and I can read them and this is it's kind of fun sometimes you can shuffle back and forth between different refactorings to see which is the 1 that you like the best which is 1 makes is most esthetically pleasing or not but to undo changes you can just say project history that do very straightforward or you can select specific points in the past and that she wants to undue so you can go maybe for refactorings back in undue or we do it as the case may be but this is this is transitive maybe transitive strong but it will undo all dependent changes if I undo my most recent change all right and my 1st change has and you all the ones that have you come afterward so we don't undo all the changes and the same with read exhibited do that of course if just can't stand your code in all likelihood you wouldn't want that are we doing changes is very similar there's a thing called the we do list you look things up and that some and cost you would never do this manually you know what you're writing code to do this you want your IDE again to be asking the history object what is there and explain it in a nice Windows you can check boxes and stuff and decide what to undo and redo however this is just the API at the at rope another really interesting and very powerful features multi-project refactoring you may decide you have separate projects in different directories in different places that you know that they rely on each other when 1 depends on the other you want refactoring that most applies this project also be perform in this project and row can do that but at a very high level it works like this you you create a multi-project refactoring you given the refactoring tied in this case we name that you want to do just use renamed for all my examples here this many other refactorings you construct this multi-project refraction Intel the other projects not your main project all the other products you'd like to start operate on it and remember these are just projects built on some other directory tree somewhere and then you can I use the impurity multi-project refactoring there to construct the unbound refactoring just like we did earlier than you create changes like we did earlier and change it this is clearly something who likes job because it's the enterprise proxy manager implementation factory factory and that and then you would do multi-project and perform on the changes that the multi-project API is a bit weird and it took me basically a lot of experimentation figure out how it worked but it does work I can say that with with with with good governance and works as well as reports on single single projects which is not perfect all the time we talked a lot about refactoring things and he's refactoring things that broke does they have a lot of obviously non refactoring little things like you know finding on docstrings and finding definition points and so forth is a great idea and tools as well frankly I use jet I for a lot that kind of stuff now but I still use rope controlled for Puri factories I've said this many times but was not intended for manual operation it's which really tricky get right and let your ID to the hidden lifting for you but an integration told you that thing for you and that is what trot retro comes and its property is
on what is the definition of this since of of the above about what's Norwegian for forever but it was kind of witty of you broke thread OK of little protein if if found if you need find names for your projects where a foreign language and just use the foreign languages word for that I'm not a region of obvious I just I just picked trod and nobody in the world that is drawn for project name so it was wide open so but what it was what what is strong try this day and age she Jason server wrapped around world that's all this all is put in HTTP API on top a rope so you can call it easily they also includes why say various clients were driving right now contains 1 and that's for the the next slide by using that since I need this tool based I at this so the idea is that your IDE German the maximal studio whatever consent aged Beijing http Jason requested draw work on the file system do the work for you it's great that the embedding is really really easy the embedding of refactoring tool in x is really simple because it's just so simple so Weintraub why why did I go through the trouble of writing this are existing tools Directorate wrote for the next so 1 is simple integration with editors everything in the world now my watch probably this table speaks 80 http
Jason right so it's easy to to send these messages back and forth so I don't have to worry about embedding the Python interpreter matter something along those lines which is technically feasible and I know how to do it but it's more complicated than it needs to be http is way more than fast enough for this kind of work of people celebrate on is sending messages or it could be what response times none ATVs way faster than you can blink so of course it's fast enough for this kind of work the real-time involve the refactorings is the factories themselves as decided don't to worry about overhead or sorry latency so this is really a great way for me to support multiple versions of Python in in 1 you max if I was embedding the Python interpreter max I based at the pick the 1 I wanted were jumping incredible groups to have Python 3 in Python 2 embedded in emacs as this that's all separate processes is really easy in with the maximum very little about the distinction of between 2 and 3 and as a little bit because I have to tell but very very little and this really simplifies to 3 concurrent development especially over multiple projects it's it's architectural when in many many ways it's the proper level of abstraction the rule that the job of trawled is python refactoring not being embedded in an idea so this is likely to pull them apart and
really work at the proper level of abstraction see solved the most heinous religious wars in the world now in actuality I because they both use the same tools of all returned tools like this we would have to playing with all use the same tools really under the hood users have different key bindings right so it's that it's that simple bleeding and so little bit about the architecture of time here sounds like to talk about the Python goodness for the most part I use model for the HTTP handling bodily wonderful anybody here involve a bottle thank you it's brilliant really is I just copied ball PY dropped muscles structure there I
don't worry about dependency theory like that just works and it's also possibly easy-to-use thank you very much that you need to do http handling use models where this never went up Pike at pick who knows how to pronounce this Victor OK you should know because you wrote about believe right yeah OK at the thank you take it is an actor model implementation in Python which is hence the you were here this is that's in Austin it is also as well it's not that I started the implementation of for without that and I had in handle my own concurrency because you need concurrent asynchronous handling of requests because some factors can take a long time especially large code bases what what I switched actors based I did have to think about it anyway this is another huge architectural when I knew that my state in this actor was distinction by stating the other after and I didn't have to worry about locks for anything he just works it just works in it it consists of the the biggest 1 is not even concurrency which I don't really get it's the conceptual clarity of the program itself so if you've never used actors and you have concurrency nightmares is working for the headaches really make a branch for pick up on your product and tried I can almost guarantee that you're of it it's so even any actor model status is essentially actor model try that status is incredibly cool off many other reasons as well and so this is another big when so thank you thank you for that the Architecture Library architecture which has has what has to have boxes and lines so required by Europe I to do this you model the front receiving all the inputs into actors the project which the thing that kind of OK thing the kind of handles all the actually talking to wrote so it you know it takes the requests for during to extraction method etc. and you can see that it works directly on the file system which the editor was also looking at the way in which is a bit of a trick sometimes on the other actor is the state which basically is a a thing to keep track of the request to the state of that request and that can be queried through bottles well hence the line obviously the casting like as it is just a mapping of integers which is just increasing integers whoever request maps to whatever the status of that thing happens to be failure or pending war success on a sort free free-form thing I don't use it much except to keep track of its going on right now by simple and the state actor but that the state object the the tasks that object is an actor and thus from colored
thread-safe that's a reasonable term used for this some religious leaders asynchronous safe multiple asynchronous tasks can be accessed anytime I don't have to again think about locksmithing adjust magically works because there there's you realize messages and the report they have enough time to talk about this the the the important part here is for the asynchronous operations into also some request becomes in for rename that's asynchronous because it might take a long time that the request back immediate task ID and then that's done from the client's point of view the client and then come in later and ask for task 23 and get satisfactory all the all the renaming actually happens asynchronously us a synchronous things happen much more simple way find definition we want that to happen as fast as possible but no reason to continue without the reason come back to the IT into completed so this is a synchronous operation of there you go you know and and the distinction there's a couple of asynchronous things renames
extracts organize important as a couple of synchronous things things like find definition get history find a call to have that kind of stuff those are all of synchronous I love the max I had the status and really really at the drawn in X is the only editor a regular place where you struggle with that I know that's usable actually so the code for using Emacs the axes there's very simple trod open in children and it's really that but straightforward because the max because the next knows where my cursor it'll be i for that matter knows where personal is strawberry raging raw from an asterisk on that I wrote that it works because you don't have to tell it where to do it from the next figures it all out and this is this is letting your IDE do the heavy lifting of figuring out where to refactorings and stuff that's by keeping that point of this is what I mean this is what the issue he messages that like as they come through of probably only the anyway right so come on time about OK so I could do demos we could take questions the demos or just using the next usually factories and so there are questions that we can start with that and I can demos later people and see what all all of the world this yeah repeat questions so that the question finally had to do with it but I have a rope doing work on files and also the max looking at these files potentially doing things at the same time right now that interaction is very dirty crude and I just like what I means part stack of a little here and the only person strong as far as I know so works for me that's the price I my my Emacs set up to once a 2nd refresher revert any buffers that have changed on this so I know that before I do refactoring I just say my file new factory there are ways around this of course because 1 of things I can ask brokers what are you about to change right and it can tell me here's a about changing after refactoring is done I can automatically over all those buffers I have written the logic to do that but I'm accepting patches so force if you wanna do something like that of more than happy to consider a and but you do have to be a little bit careful about so that kind of stuff and you can of course get into weird situations where you've made your own editing the maximum the files can change to 3 times necessaries condition and I say don't other questions yes this 1 the goal has the do you think you know that was this is not a lot all I I I I don't fully understand what what it is you're asking about a and a mechanistic renaming of of arguments of that means OK but the answer is maybe I don't know wrote Detroit trotter with the Bush was not something I don't I don't know sir and but drawn has a lot of functions I don't expect sorry rope has a lot of functionality that i don't expose right now in intron so if you are missing some feature of we can explore or whether or not existing reporting to be added or what the status any other questions OK
what we've got a little bit of time so again you asked for it & price of this is this is the max
and I'm going to do a profound sense of 1st introduced start the transversal
troponin I tell it the
directory right and you can see of course that OK max is kind of managing this process the strolls
service without some information so that's that's struggling under in access control now mean that
data if I can you my should be able do this and I make the font bigger I'm sorry where you can kind of see that the point is this on the right is my unit tests for my collision detection can increase scale in the text scale increase they would that are involved in here
I probably the Yankees
yet what question I get all that great in the middle of the this is how I spend my time OK so we got we got this function calculate collision vector which is defined and inclusion of the wife was attraction stuff for my last words came in over here is the unit test the same in my unit tests and I for some reason side I don't like that right so I can say control which your are reading that you know how Call it think about it for a few seconds and this this is kind you're getting you in the 2nd row about that the timing but you can say OK now it's it's changed from I should get it wrong and that's OK by changing everywhere you could you could find so changes not only in the call here the test but also the definition 1 shortcoming I don't know the solution is does this in these all these things in cracking indented from that's English from a rope shortcoming that I would like to get fixed so if I don't like those I can now I display the history now and I can see and got this 1 thing that I can and which was renaming calculate collision acted account all
that I do wanna do that is actually not on the name I want to give it some of 2 of them do and it will think about it for a few seconds and
then I promise it will never know the history doesn't automatically updates so it's just ignore that for now that's another fixable thing but that some this sort of the the main things India for it's it's just in every so if I killed the transceiver it's gone as far as I know it might be serializable but I've never try never looked into it it's ever been issued from basically and 1 on the 1 hand a cool thing that a lot of my appreciate when they're starting recording codebases making cleanup rope clean up your imports and in certain ways and so intro 5 I created the commander trolled imports super smackdown images runs all of the organizing and cleaning up and imports from middle child it does it in a 2nd later it will
but OK see in that much nicer than others and being in important dot dot all that kind of stuff it's all that and of course I can but and do that so I that's it for the demo there's no more questions OK and he he said a on you know we are
using also right you understand what I'm to about or in decorators and that's a really good question I don't know but I've had that yeah like I said I am the only 1 to this so if I've I've ever had to do it I don't it works of art and I would think of his rope is pretty darn smart wrote does incredible things and well beyond what I would imagine be doable with refactoring tools and languages and amicus Python but how we can intriguing tried out later should be hard yeah anything else program was of the last slide there's some links all this stuff the presentation is on github you have
such a thing and you can find it on wings everything else and thank you very much few
Domain <Netzwerk>
Vervollständigung <Mathematik>
Einheit <Mathematik>
Tabelle <Informatik>
Objekt <Kategorie>
Spektralzerlegung <Physik>
Mathematische Logik
Spezifisches Volumen
Weg <Topologie>
Architektur <Informatik>
Konvexe Hülle
Verzweigendes Programm
Binder <Informatik>
Offene Menge
Wort <Informatik>
Faktor <Algebra>
Persönliche Identifikationsnummer
Baum <Mathematik>
Prozess <Physik>
HIP <Kommunikationsprotokoll>
Metropolitan area network
Eigentliche Abbildung
MIDI <Musikelektronik>
Lineares Funktional
Topologische Einbettung
Projektive Ebene
Iteriertes Funktionensystem
Physikalische Theorie
Puffer <Netzplantechnik>
Operations Research
Bildgebendes Verfahren
Leistung <Physik>
NP-hartes Problem
Objekt <Kategorie>
Demo <Programm>
Desintegration <Mathematik>
Computerunterstützte Übersetzung
Deskriptive Statistik
Kategorie <Mathematik>
Güte der Anpassung
Zeiger <Informatik>
Kontextbezogenes System
Dienst <Informatik>
Rechter Winkel
Wurzel <Mathematik>
Zellularer Automat
Grundsätze ordnungsmäßiger Datenverarbeitung
Elektronischer Fingerabdruck
Klasse <Mathematik>
Inklusion <Mathematik>
Elektronische Publikation
Data Dictionary
Patch <Software>
Eigentliche Abbildung
Formale Sprache
Snake <Bildverarbeitung>
Einheit <Mathematik>
Prozess <Informatik>
Mixed Reality
Stützpunkt <Mathematik>
Figurierte Zahl
Serviceorientierte Architektur
Nichtlinearer Operator
Konstruktor <Informatik>
Zentrische Streckung
Prozess <Informatik>
Ganze Zahl
Overhead <Kommunikationstechnik>
Proxy Server
Interaktives Fernsehen
Keller <Informatik>
Kombinatorische Gruppentheorie
Elektronische Publikation
Einfache Genauigkeit
Endogene Variable
Mapping <Computergraphik>


Formale Metadaten

Titel Python refactoring with Rope and Traad
Serientitel EuroPython 2014
Teil 97
Anzahl der Teile 120
Autor Bingham, Austin
Lizenz CC-Namensnennung 3.0 Unported:
Sie dürfen das Werk bzw. den Inhalt zu jedem legalen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen.
DOI 10.5446/19947
Herausgeber EuroPython
Erscheinungsjahr 2014
Sprache Englisch
Produktionsort Berlin

Inhaltliche Metadaten

Fachgebiet Informatik
Abstract Austin Bingham - Python refactoring with Rope and Traad Rope is a powerful Python refactoring library. Traad (Norwegian for “thread”) is a tool which makes it simpler to integrate rope into IDEs via a simple HTTP API. In this session we’ll look at how traad and rope work together and how traad integrates with at least one popular editor. ----- Python is a modern, dynamic language which is growing in popularity, but tool support for it is sometime lacking or only available in specific environments. For refactoring and other common IDE functions, however, the powerful open-source rope library provides a set of tools which are designed to be integrated into almost any programming environment. Rope supports most common refactorings, such as renaming and method extraction, but also more Python-specific refactorings, such as import organization. Rope’s underlying code analysis engine also allows it to do things like locating method definitions and generating auto-completion suggestions. While rope is designed to be used from many environments, it’s not always easy or ideal to integrate rope directly into other programs. Traad (Norwegian for “thread”) is another open-source project that addresses this problem by wrapping rope into a simple client-server model so that client programs (IDEs, editors, etc.) can perform refactorings without needing to embed rope directly. This simplifies dependencies, makes clients more robust in the face of errors, eases traad client development, and even allows clients to do things like switch between Python 2 and 3 refactoring in the same session. In this session we’ll look at how rope operates, and we’ll see how traad wraps it to provide an easier integration interface. The audience will get enough information to start using rope themselves, either directly or via traad, and they’ll see how to use traad for integrating rope into their own environments. More generally, we’ll look at why client-server refactoring tools might be preferable to the more standard approach of direct embedding.
Schlagwörter EuroPython Conference
EP 2014
EuroPython 2014

Ähnliche Filme