We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

PyCharm tips and tricks

00:00

Formal Metadata

Title
PyCharm tips and tricks
Title of Series
Number of Parts
160
Author
License
CC Attribution - NonCommercial - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
PyCharm tips and tricks [EuroPython 2017 - Talk - 2017-07-12 - Anfiteatro 2] [Rimini, Italy] PyCharm, a Python IDE with its free and open-source community edition, in last several years has become a tool of choice for more and more Python developers. But not everybody uses its full power. Moreover, most only use a fraction of the functionality it provides. The reality is that an IDE is not just about a set of integrated tools, but an environment that understands the semantics of your project, of what you’re doing. It can leverage this to provide you with functionality that can make repetitive mundane tasks become frictionless, as well as give insight into potential problems. In this session, we will go through the most powerful features the IDE offers and whether you do web development or work with data using Python, you will benefit knowing how the IDE can leverage your programming skills
SoftwareRead-only memoryStatisticsBefehlsprozessorUsabilityMetropolitan area networkRootQuantumCloud computingMassRange (statistics)PlastikkarteHydraulic jumpCartesian coordinate systemPressureProduct (business)INTEGRALResampling (statistics)Endliche ModelltheorieRevision controlProjective planeTheoryGEDCOMPresentation of a groupShared memoryMereologyConfiguration spaceMassMobile appInstallation artIntrusion detection systemRollback (data management)AreaFeedbackBitPiProfil (magazine)Lecture/ConferenceComputer animation
Read-only memoryBefehlsprozessorStatisticsMenu (computing)Mach's principleSimultaneous localization and mappingNavigationBit rateProfil (magazine)Software testingProjective planeComputer filePhysical systemDirectory serviceOpen sourceEndliche ModelltheorieSocial classRevision controlMultiplication signThermal radiationSubject indexingProduct (business)CodeInternetworkingElectronic mailing listShift operatorType theoryTouchscreenRootGame theoryNumberVirtual machineFlow separationRight angleMoment (mathematics)System callFile formatDirection (geometry)Link (knot theory)CASE <Informatik>PressureArmDefault (computer science)Set (mathematics)Different (Kate Ryan album)Computer programmingNatural numberGreatest elementStandard deviationDilution (equation)QuicksortIntegrated development environmentPrice indexMixed realityConfiguration spaceDivisorFunctional (mathematics)Point (geometry)Computer configurationGroup actionComplete metric spaceModule (mathematics)PiKeyboard shortcutSampling (statistics)CloningFormal grammarWindows RegistryRoutingVirtual realityUltraviolet photoelectron spectroscopyGoodness of fitUniform resource locatorComputer animation
MassGroup actionRouter (computing)View (database)Price indexFluid staticsCodeOnline helpBeta functionGame theoryInclusion mapNavigationSymbol tableComputer virusoutputRevision controlEndliche ModelltheorieDiagramField (computer science)Software testingComputer fileCache (computing)Open setUser profileLocal ringAsynchronous Transfer ModeSimulationImpulse responseFunktorMaxima and minimaData structureCase moddingUnified threat managementFunction (mathematics)Demo (music)SummierbarkeitMIDITime zoneJunction (traffic)Source codeExtreme programmingGroup actionEndliche ModelltheorieDiagramSymbol tableComputer fileMereologyCodeSet (mathematics)Projective planeMultiplication signFood energyType theoryShift operatorData structureSource codeTheoryIntegrated development environmentNegative numberSocial classDefault (computer science)Level (video gaming)WeightCondition numberKeyboard shortcutCore dumpField (computer science)Text editorView (database)Doubling the cubeWindows RegistryPiWindowComputer animation
Network topologyInclusion mapEscape characteroutputDemo (music)PlastikkarteNormed vector spaceRankingHydraulic jumpData modelMenu (computing)Meta elementSimultaneous localization and mappingStructural loadAsynchronous Transfer ModeFreewareMach's principleLeakHill differential equationNewton's law of universal gravitationWaveComputer wormTwin primeExecution unitMaxima and minimaComputer fileCASE <Informatik>NP-hardNegative numberKeyboard shortcutGreatest elementProgrammschleifeAdditionDisplacement MappingPopup-FensterMobile appProjective planeDebuggerEndliche ModelltheorieVariable (mathematics)Focus (optics)Network topologyData compressionBoris (given name)Directory serviceSpeech synthesisWeb browserText editorSpacetimeMultiplication signRevision controlData structureType theoryPerfect groupLine (geometry)WindowGroup actionDirection (geometry)Vector spaceRight anglePiConfiguration spaceSelectivity (electronic)Set (mathematics)InformationAsynchronous Transfer ModeBitPairwise comparisonPosition operatorTouch typingWordComputing platformFreewareView (database)Intrusion detection systemTap (transformer)Logic gateComputer animation
Latin squareMaxima and minimaTwin primeInclusion mapLevel (video gaming)Default (computer science)Key (cryptography)Execution unitEmailMathematicsLipschitz-StetigkeitCodeSummierbarkeit19 (number)EmulationMultiplicationLine (geometry)Menu (computing)Manufacturing execution systemSoftware testingGame controllerCondition numberRevision controlSystem callResampling (statistics)Library (computing)Web browserObject (grammar)Distribution (mathematics)Element (mathematics)Projective planeShift operatorLine (geometry)Complete metric spaceType theoryVideo gameCodeSoftware developerReading (process)Point (geometry)ImplementationINTEGRALBranch (computer science)PressureCellular automatonMultiplication signRight angleMereologyMappingParameter (computer programming)State of matterTouchscreenGoodness of fitKeyboard shortcutTap (transformer)Probability density functionPixelLevel (video gaming)Closed setMagnetic stripe cardKey (cryptography)InformationOperating systemHeegaard splittingBus (computing)Presentation of a groupComputer animation
CodeComputer fileMaxima and minimaRange (statistics)Lemma (mathematics)NavigationEmailLinear subspaceView (database)Moment of inertiaMathematicsDenial-of-service attackServer (computing)LengthExecution unitIRIS-TFAQScalabilityMenu (computing)Normed vector spaceInclusion mapPointer (computer programming)Mach's principleMass flow rateQuadrilateralLogic gateRoutingBranch (computer science)WindowINTEGRALRadical (chemistry)System callOperator (mathematics)File systemWordObject (grammar)Code refactoringGroup actionCodePairwise comparisonDifferent (Kate Ryan album)Directory serviceComputer configurationError messageRight angleContent (media)MathematicsProjective planeText editorComputer fileRevision controlWeb pageSoftware testingMoving averageSoftware developerRollback (data management)Local ringBlock (periodic table)Greatest elementMathematical analysisIterationForestCommutatorInsertion lossElement (mathematics)Computer animationLecture/Conference
MaizePlastikkarteParsingCommunications protocolComputer fileGoodness of fitRight angle2 (number)GenderKeyboard shortcutProgrammierstilAnalogyLine (geometry)ConsistencyLogicQuicksortComputer animation
Group actionNormed vector spaceGamma functionMenu (computing)Execution unitCone penetration testDean numberMaxima and minimaSimultaneous localization and mappingPersonal identification numberLogarithmMotion blurCodeStatisticsComputer fileNavigationBinary fileDigital rights managementPermianMeta elementInclusion mapDirectory serviceStatement (computer science)Line (geometry)Multiplication signComputer clusterCodeMathematicsType theoryTransformation (genetics)Server (computing)Source codeIntegrated development environmentTable (information)Projective planeDatabaseReal numberComputer fileRadical (chemistry)Set (mathematics)PiProgramming languageVideo game consoleVirtual realityGroup actionProfil (magazine)Instance (computer science)Software testingTriangleConfiguration spaceGreen's functionRight angleCASE <Informatik>Query languageBefehlsprozessorWeb browserProduct (business)Complete metric spaceFunctional (mathematics)Event horizonFigurate numberDirection (geometry)Degree (graph theory)GenderPressureExecution unitOffice suiteSystem callCellular automatonBit rateSheaf (mathematics)Natural numberData loggerStochastic processMedical imagingTask (computing)Online helpPoint (geometry)Parameter (computer programming)Computer animation
Mass flow rateCodeMaxima and minimaLimit (category theory)Computer wormDrum memoryEscape characterInclusion mapGamma functionWeb pageGroup actionSimulationExecution unitEmailPredictabilityMenu (computing)Regulärer Ausdruck <Textverarbeitung>Scalable Coherent InterfaceRegulärer Ausdruck <Textverarbeitung>Semantics (computer science)InjektivitätFormal languageWritingSquare numberTable (information)CodeComputer fileSelectivity (electronic)Variable (mathematics)Functional (mathematics)Token ringType theoryDampingGroup actionRight angleSoftware engineeringUniverse (mathematics)DebuggerKeyboard shortcutComplete metric spaceContinuous integrationLocal ringProduct (business)File formatPoint (geometry)Video game consoleWordLine (geometry)Buffer solutionTraffic reportingMultiplication signText editorValidity (statistics)CASE <Informatik>Serial portPressureCache (computing)UsabilityStudent's t-testBit rateRevision controlCondition numberPresentation of a groupSource codeMarginal distributionBinary codeTerm (mathematics)Forcing (mathematics)SoftwareString (computer science)Theory of relativityExpressionLevel (video gaming)Bridging (networking)Letterpress printingStress (mechanics)Logic synthesisLatent heatPairwise comparisonMilitary baseStandard deviationCovering spaceElectric generatorAdditionShared memoryException handlingAreaMusical ensemblePie chartLoop (music)Information retrievalComputer animation
Complete metric spaceSocial classTemplate (C++)SpacetimeView (database)Escape characterSieve of EratosthenesBenz planeMaxima and minimaWordPhysical lawVarianceBitError messageWordInteractive televisionFunction (mathematics)Electronic visual displayFlow separationComplete metric spaceWindowText editorGroup actionSocial classType theorySubject indexingContext awarenessMultiplication signSemantics (computer science)SpacetimeNamespaceComputer fileLine (geometry)Module (mathematics)Document Type DefinitionArithmetic meanRight anglePie chartFood energyResultantConnected spaceComputer animation
Transcript: English(auto-generated)
My name is Dmitry the first question maybe is not expected like who of you swam in the sea today in the morning Yeah, I did also that is amazing yesterday I didn't do that because I was lazy wanted to sleep more, but my colleagues persuaded me to go to today
I went and that was so amazing do that tomorrow if you survive a party or Anything but coffee helps after but this it is worth it definitely Wow, thank you was great
so The second question who you already uses use pie charm Almost everybody that is so nice so I will try to focus on tips that are maybe a bit more advanced and unexpected and
My goal for today is like everybody knows at least one new thing in pie charm Also, I did some kind of that talk a couple of months ago three maybe a month ago at picon, Italy
Anybody listen to that talk by con Italy or Okay, one person there won't be many new things there will be maybe three three four Things that I added but mostly it is almost the same same talk
But we'll see so the first thing that I want to show is the thing that I didn't mention In Florence is The new kind of product of jet brains that ties together all other products that's called toolbox app
Anybody knows about that? Who knows? Nobody knows great. So I'm done So easy toolbox app is an application that allows you to Manage easily the tools and the projects so you have here two tabs That's your
Projects and that's your jet brains IDs and you can update you can rollback updates. You can install new versions and It's very easy to track what versions do you have and it was very easy to launch things from here For example, you have four different projects. You can have different configurations
For some projects you can use EP By the way, hope you use a piece early access builds Great, please come to our booth and we will give you a t-shirt because the people who use a piece first of all, they get a new features earlier and then
the most important then can help us actually to make those features much better because they Submit the feedback area and It's much easier to fix stuff before you released the feature because after you can move on to other things and So I encourage you to try a piece. They are pretty usable
So Let's start Here we have Toolbox and we can launch from here by charm. So it's by charm community by charm professional in theory Just present will open but I already has have it opened
That's by charm. You know it and for today's presentation. I will use the project called VM prof VM prof is the profiler that was developed by By pie guys that's initially it was massive alcosky and Anthony Cooney who are there The conference you can meet them and they came up with this profiler like to your Python three years ago
I think and it is very nice sampling profile it also it has it's open source and it has UI the improve calm which is written in Django and that's why we'll use it as a Sample project because it's not very big and not very small
It's very good to show stuff. It's on github. So what we do in pie charm to open projects we go and we can check out directly from version control, so we just press github and a Clone, but that won't work because internet here is so slow and I'll open already
Already clone project instead So what do we do? Normally when we open a project so most of the time first we want to learn what that project is and we want to To read the code and in pie charm you
You can of course do that file by file, but the easiest way to do that is use search and In pie charm, for example, you know that Django project so you can press command shift N and you can type URLs and You can navigate directly to this file and you see that
Pie charm shows you the list of the files very fast and why is it so fast? Actually, it's not it is very fast because we have indexes and this speed of Access to all the files and classes is not free and you pay for it by indexing and people complain about indexing
why do you have indexing the big one by charm stars and So indexing is payment for speed ups later So you can access your code very fast because of the indexing so indexing will stay forever We work constantly on improving the performance. So this Cost this payment decreases every year every month. We try to optimize them but still indexing is a good thing
So, yeah, and let's return to our urls.py how do you navigate in pie charm you can actually go to You can read the code yes in all editors, but also what you can do you can press command and
Click and go to all the Functions No, it's not. It doesn't work while it doesn't work. Yeah, I forgot to tell you important I think it doesn't work because in interpret is not configured and by charm tells us about that and we can press this link and You see that interpret is not configured and what we do first
Normally when we open the project we create a virtual environment So in by charm, there is a button for that you Press this Option and you type VM Pro server Something like that and you select Python 3.6
And by sham creates virtual environment For you and after that you can use it But what we have now is by charm actually tells us also the dependencies are not installed
How much I'm knows about that there there is a file called requirements dot txt in the project and Actually, if I shall question found it automatically if by charm doesn't find it. You can go manually and Set up it here. So you see that requirements dot txt is selected and actually that's the way to change your
environment because sometimes you have different different setups for testing for production and You can select here different requirements and you just press this button and here comes one very important and not very obvious tip
so when when we open this window, it's Or stand default file chooser. Yeah
Yeah, that's a very good answer because set up the PI is a Python file we cannot execute it and you can specify dependencies in a lot of ways instead of set up the PI and require
no, we use requirements dot txt because it's like machine readable format and it's like I Advise you if you didn't listen to advise you to listen to the keynote of Armand Orner here on the first day he talked on this topic, so
The requires dot txt is a direction in the right in the right It's a movement in the right direction in Python. So you have dependencies in a clear Specified a clear formal way and it's machine readable. It's easy to understand and set up the PI You can like it's Python file. You cannot you can introspect that but that won't work in all cases
So we don't encourage you to write dependency there Sorry, we don't support it Yet, it's not standard. That's Some experiments as far as I I know
Does anybody have a question about? This No, so let's proceed I wanted to show like Other here OS 10 users who uses mark OS 10 Yeah, the steepest for you. This is like if you want to choose a file in PyCharm and you see this screen is
a default File chooser and it's not very convenient. It doesn't it's it's just just bad So what you can do in PyCharm, you can actually use the feature called registry it's
Set of hidden settings more like system settings and you can open them and you can see there a lot of a lot of settings and one of them is mark file chooser native and we disable that and
After that we return to Our file chooser and you have here much nicer UI you can navigate to your project route to your home directory and you have Auto completion here and it's so nicer But we'll leave it as it is so we select
production Dixie and you see by charm now understands your project when the interpret is selected Highlights is red and you can install requirements. We won't do that again because internet Won't allow us to do that instead We take already
configured version Yeah, and after we configure that we can navigate to all our classes and Modules and we can do whatever we want with that and There are several
Several actions I showed showed already go to file. It's common shift and by the way, you can see this hint in the Bottom of the screen it highlights a shortcut There are several others for example Commandant is go to class so you can type class and it will show it you can show actions
In the ID, so as I did for registry and there is a general Action called search everywhere. It's double shift and you can type Whatever you want and it will show both
Classes and fast and it's all actions as well So there are a lot of ways to navigate through your code actually A Navigation that knows everybody but there is one more thing. For example, you have a lot of models like let's go to
some Jenga's Django There is one more by the way showed it's called a fine symbol we can go to Models Like you you can introspect models going one by one using
Go to definition. That's cool. But there is better way which is very not obvious in in pie sharp professional features available in professionalization as well as Django support in general you can see the Diagram you can press show diagram pop-up and there are several diagrams that you can
Open and that is for example Django models diagram So if you have some unknown Django project you can just open it in a visual way and See how it looks that is much faster than Go from file to file. And of course that is much faster than just read the code in text editor
Yeah, another way how you can learn about your code is Structure there is a tool window for that. It's called structure window and it shows you The top-level definitions in your file and also there is a
Structure file structure Which you can invoke with a shortcut and here you can also navigate very easily it shows you a top-level definitions with classes shows also fields so It can be very handy when you you are somewhere in the code
Given the code and you want to see where where you are. What is the context? outside of the file you want to go fast to your file structure There is a shortcut for that. It's very handy. I use it all the time. It's at F1
And you can navigate to the project view by a center and You see where you are and there is one more thing you can get go even further there is a setting which is not on by default and Not very many people know about that you can enable auto scroll from source here in the industry
You enable that and then? Wherever you are the file tree is updated In synchronized with your editor So the active tab in the editor is shown as it's selected in the file tree
speaking about the file tree Project project file tree as all other trees in This pie in pie charm and all other IDs are searchable And that's also not what all people not everybody knows you for example if you have a focus in the tree
you can start just start typing you can type apps and You see that the focus moved to the observed by and also after that you can press up and down For example we press down and we iterate through the highlighted
Items that is very handy and that works for all the trees for example the same thing works in the debugger when you have your variables you can start typing there if you need to You feel looking for some variable or even for some value you can start typing and it will only need
in the variables view in the debugger Right so yeah some sometimes people say that like yeah, I Said the word tabs and that remind me that like sometimes people say that by charm is like a bit Complicated in comparison with
Text editors, and when you try when you start to ask why? People say there are a lot of things like you have two windows you have tabs you have like Bars buttons and actually what you can do in pie charm and what a lot of people do Is you just can remove out that all and I will show you step by step how you do that?
For example nobody needs those buttons if you have especially especially when you use shortcuts you You might be using those two to run things and these two select run configuration but you can do that with shortcuts, so you just
Just press this no, it's not this toolbar and It's gone, right so here you have Rather convenient navigation bar you can select here Directories and you can go to the files, but actually it duplicates
What you have here? So you can remove it as well Navigation bar you press here, and it's gone But if still if you need that you can invoke it by the shortcut, which I don't remember
No, it's yes hardest on OS6 but even you have a shortcut, and you can do everything you want from here you can Navigate and even create you can create file files from here Just in the edge, so I think this is much better than having the navigation bar on the top
What we do next of course we don't need all those tools like the data view We don't use it for now, and we can like pressing here. We can remove that steps steps Informative but some people say that they eat too much space and we can configure that as well, so we go
Type steps here, and we have here the main setting is placement and placement Can be can be top can be left can be bottom can be right and like it can be none so we move steps to death now and
We don't have tabs and You see here. We have like Minimized version of pi charm that actually looks like sublime text or any editor that doesn't look complicated it looks very light and We can go even further and
We can enter Distraction free mode the special mode that actually automatically removes everything So yeah, it looks like that removes the project window and It removes the left gutter, but I don't like it myself because It removes gutter, and you don't see breakpoints here when you debug it
I don't know whether you see it here, but breakpoints highlighted as Pink line, and it's not very visible. It's not very convenient for me, so I don't use destruction free mode I Just remove everything by by myself, and if you don't need project you can you can collapse it
You can go there only when you and you need that So how do you navigate between your files when you don't have taps when everything is collapse? one the most frequently used
Action is recent files so it's Command-e and here for from these Pop-up window you can navigate to the recent files and also can we gate to the Tool windows for example if you switch between two files you can just do like that
You can you can you press command-e and you go to rotus and you press Command-e you go to models, and you don't need to touch your mouse and move it to the first step then edit something Touch it again move to this second tab this much faster another thing is
You can actually go back and forth with a shortcut, so it's there is a shortcut command-alt-left and command-alt-right and For example you went somewhere you edit something and you want to return back And so what is back is not different story But you know what you want to go back like in browser, so you can press alt comment left, and you actually go back
But it's not not it tracks not only files But also positions and files so if you edit it someplace in one big file And you go to the another place it will return you inside one file as well, but it's also very handy
as I told you Go to file is a perfect way to navigate so you don't need that Taps, so you just if you if you remember the names you just type it you go Right so Yeah, okay, so what do we do?
Do you have any questions by the way About navigation or maybe maybe you know some tip that I forgot to show by the way I don't know all the intelligent platform
I develop a charm for seven years already, but intelligent platform has so many features and all the features it has First of all a lot of features I don't know at all I don't know that they exist and I learn all the time something new and and I Learn I think I learn slower than they are being developed
And there are some features that I know that exist But I don't use them, and I think that happens always with new tools with new features that people Like they know that something exists But they don't they don't have time to invest to learn something and they think okay I will do the old way because I'm quite efficient doing the old way
but It happened with me a lot of times with IntelliJ then I learned some new ways I'm new feature and you spend some time learning the new way And then you understand that the old way was just so cumbersome so time-consuming and you start doing Something new and it's very efficient
So I encourage you to learn not especially of course Python because you already use passion But it's it applies to all the all the tools and just learn new things Yeah, that's advice for myself Yeah
Summary of shortcuts yeah, we have actually if you to help you have here key map reference you Yeah That was something I printed for my daughter And you have here the nice PDF that is
That contains all the shortcut for your operation system also The conferences we have printed key maps, but I don't think we have now
Yeah, very nice thing if you yeah, it's it's so good I will show you that if you still use steps If you still use steps Let's enable them you have several taps right and you want to
Like to close them in PyCharm You can easily close everything by shift-click. So you just you don't need to target this little Cross so you just you just press shift and you click Shift and click and you can close everything by that shift click close everything. It's very very nice tip
It saves time. You don't need to find the pixel. Yeah. All right. Let's write some code. So We read through the project
We know something about that About the project and we need now we want to add Some lines of code and We start doing tests during development. We Start by adding some tests So we go and write something and you see that
It's not a good example here. You see that PyCharm completes the All the syntax that actually you don't need to type that is obvious by charm types for you but this Makes the life more difficult for some people because PyCharm completed itself and it closed the brace and added this
Semicolon, but what do you know? What do you do now from that? How do you proceed? Does anybody know how to proceed from this point? The fastest way how you to start writing the implementation of the test function. Yes
Yes It's shift enter actually, not everybody knows that so You can like press down but then you go to the beginning of the line or you can go left left enter That works, of course, but shift enter much faster
And we type something like that self And from here you can actually invoke documentation present Control J. You can view documentation just from the completion So for example, you take an object and you want to invoke a method. Do you want to read the computation?
You just make what can do that from from here you can Do that Read and you actually can start exploring the library from here like you can it's like a browser. It's very handy Yeah, and you also what you can do
No, no, okay, no, I won't show that you you can actually what you can do is you can I don't remember the shortcut. Unfortunately, you can show the definition as well So right from here, for example, if you don't have documentation if you use some of your library that doesn't have a documentation you can
Show definition right from here from the completion and you can like see how it is implemented to know what to execute That is very handy as well. So it's a philosophy says can save a lot of time Alright, let's we know what we want to execute. So we execute that but we don't know what to enter and by charm shows you the
arguments if it doesn't show you you can invoke parameter info with command P and Yeah, and you see that by charm also highlights you if argument is missing, but I guess you know all that
So we write our test like that and we can run it. Alright, it's my test We just press run fails Yeah, now we want to fix it and we want to work with some code. How do we do that? There are two hints That can that might be useful
The first one you write test you write code you write this you write code what you can do You can split the screen and to have Unsplit split vertically you can split the screen and From here you can go and you for example, you can edit your code you can edit your test and work
Like, you know that I guess And another thing that I bet you Don't know is you don't need actually to run your tests all the time. You don't need to click this button
You don't need to press the shortcut. You can actually Enable the thing that's called Toggle auto test and you press this button and After you change something by sharing automatically restarts tests
and You see now the bus so it's also can save time So it runs all your tests for you Okay You probably See this green stripe in the left that's a version control integration
but first Close that as a version control integration and yes by charm as Into a lot of supports a lot of version control systems and we use get ourselves in jetbrains. So I Would say that we have pretty
decent get support and What you can do you can create new branches You passed something like that You can create new branch and you can commit And of course you can do all that with a shortcut you can write
test And you can that I bet you know that all what I want to show is not very obvious Who uses? cherry-pick working with gate
Yeah, there is a very good Tip that I will show first of all You probably know that there is a version control tool window Which shows you all an ocean file also shows git lock and from git lock you can do the following for example you can switch to the master branch and
Here you can see all other branches and we select New test the branch that we just created and there is a button which is called Highlight non-picked commits basically it compares to branches It compares the branch you selected here with your current branch
Which which you are working on and you press that and it grays out all the commit that are absent from your current branch And it's so convenient when you you want to see what was added to the branch and absent in another branch And move some commits. It's very convenient from here. You just select those. This is
This is how it is bold because it's my commit commits it highlights all my commits as bold by the way, I think I can I Can disable that but you see that those are gray this is not and from here I can press this button cherry-pick and we will cherry-pick right from here. You don't need do you don't need dash terminal at all
It's very cool My favorite No, that is unfortunately not supported
but it will there is a long-standing feature request and For some reason our developers of version control integration They were against this feature for so I don't know why but now they're convinced and they're working on that. All right
What you can do actually you can yeah, you can easily rollback changes, but you've seen that for example, you have some some change here and you can Roll back it from here and you don't and you can see the difference right in place. You don't need to see the difference
For all file Yeah about the differences. There is one feature which people don't know but it's very cool. Unfortunately, I don't know how to demonstrate it Is Compare compare files compare directory. You can compare everything. For example, you can select a folder and
Press option or command D or compare with and you can select I don't know It's you can select another folder and it will come of course That's not worry because those are two different folders But I think you see the idea that compares file by file and it can actually
There are pictures it shows you the pictures. So this is The best way I know to compare two different Contents in file system which are slightly different and you want to see what is different and maybe merge something to move some changes around
That's the best way. No right, so Yeah, a Lot of features. Yeah, you don't know so the main thing that is
So useful when you edit code is code inspections. This is inspections are Some checks that are executed on your file and they highlight some errors or the ways to optimize your code and here we have They are marked at the right scroll bar and
You can see them right here on the scroll bar. You can move slowly The mouse and you can see this cold plants you you can see all the warnings right in the editor and Yeah, what we see
Is that here in this project is there are a lot of violations of that page and we fix it with How how do we fix it was the name of the action anybody knows refactoring not exactly Yeah reformat call there are two ways of doing something with the code one is refactoring and one is
It's located here it actually It's some complex operations on your code when you rename something when you move something when you need to to check well when you do something with the
Code some object some code object and you need to check that all the references to it also updated Refactoring when you're working with just with code as with text that is like code operations And there are a lot of them as well. And one of them is reformat code. It's command-alt-l and you see that by charm
makes the code compatible with pep8 Also, though we see that here we have unused imports and we have an action for that it's called to my imports Yeah, now it's looks it looks much better and
If we scroll down what what is here we have here some Typos checked if we want we can add those words to the dictionary See here that methods are not implemented Yeah, I think it's nothing
Interesting to fix But actually yeah, we touched keyboard twice and we did a lot We did as Paul Everett called it yesterday at
By sharing debugging tutorial like the janitor work that the ID actually does it's like I like this Analogy it's like the ID does for you the gender work. You don't need to touch your imports You don't need to insert lines and move your methods. You just press some shortcuts in a second. You have the
very good code style right Yeah, and of course that all works for JavaScript. For example, if you go to JavaScript file we see here that
Those lines are not terminated with semicolon It's a question whether we should or not But if we want if we don't want we can suppress we can disable this inspection if we want We can just terminate and we can terminate statement. We can terminate the file but what we can do also and that we can do for all inspections we can select the
Folder or project and we can call the action called Inspection by name run inspection by name and Unterminated statement and we can do that for
directory for example And you see that by charm finds 494 unterminated statements and Actually, we can fix that right from here. We can press alt enter And terminate all statements. So in all project all statements will be terminated and that is valid for all
Inspections so you can apply those quick fixes. And if you don't know about that quick fix is some Transformation of your code that you can invoke manually In normally it is invoked by alt enter so in a lot of places in your code
You can just press alt enter and see what by charms offer Offers by charm can offer you to to make the code better sometimes Yeah, but we won't do that To save some time
Right. So yeah We have Django project. Maybe we should Try to who does Django by the way like Third or maybe 25% For Django, of course, you know that
There are run configurations to run Django tests and Django server Let's see that This is the everybody knows what what what is run configuration who doesn't know what is run configuration? Okay, a run configuration is The way how to run something
So there are predefined types of run configurations and In many many cases they are created automatically some when they are not you can create them by Pressing and selecting for example, you can there are run configurations to debug JavaScript in browsers to run some
JavaScript tools For Python tests for like for a lot of stuff and of course there is There are configurations for Django and the one that will try is Django server Let's run it. Just press this
green triangle and Let's go here and it doesn't work because we don't have database and When we don't have database what should we do We should run
Migrate task, how do we do that in Python? Does anybody know? Any ideas how to the best way to run the Django Django comments managed by comments?
So yeah It's right Django actually you can if you don't know you just search Django managed by managed by run managed by task, right and There is a special console for running managed by comments How it is better than terminal it's better because it shows you
Help and it shows you Expected arguments So if you don't know what come on does still you can use this console and you don't go to Django documentation Which is great, but right here you can it the console reminds you what what it expects so we run great and
Also what we need to do is we want to populate this with data and for that We start We run the improve from the terminal and As you see by sharp has terminal and the nice how it is better than an external terminal
One thing is for example here you have virtual environment already activated. So you just open a terminal you have already activated visual environment For it for the project you are using now Okay, let's type that
So that's how we run from the terminal of the improve profiler and it uploads
the snapshot to our local instance that we launched and Now I guess after the restart we have the data yes, and we can look here that our website works But also for example, we want to see the actual data. So we want to go inside the database to see what data
Is located in the database, how do we do that in PyCharm the best way like we go to settings Py I know it's not settings
Because here because no file Yeah, it's a file All right, how to by the way how to find it if it's not file. So we type Yeah, that's the way that's not I would say that this is a failure of our UX That's why I didn't find it. But also you can count it as a tip. For example, if you look for a folder in
And go navigate to file pop-up. You need to type the slash in there. I I know that It's strange That's how it works. Now. I hope we'll change that
So, yeah what we do I already forgot why what I wanted to do. I want it. Yeah, we go to databases and we see that it's real light, right? We Is quite light we navigate here and from here we press as
data source Okay Okay No, and you see that is added to the data sources and you can actually see the tables
CPU profile you can see our Entry that we just created from the terminal And also you have a SQL console right in the pie charm and you can write From and here you have also code completion improve CPU profile and you have history of your queries and so can be pretty convenient way to
to Work with databases and based on this functionality actually the brains has a separate product called data grip It's it doesn't support any programming languages. It's focused on the databases and it is included in the pie
Okay So we have some time. Yeah, and I want to show you The thing two things right in the end like I show two things there are as you know, there are two
problems In software engineering like caching validations and naming things I Would like to show you how we solve you solve that in pressure
For caching validations and that counts as a first tip. I want to show Sometimes by charm can highlight some imports as red for no particular reason and That is the first problem caching validation says it means that we could not invalidate caches and there is
action called invalidate cache and restart So you might try that but it happens very rarely But sometimes it is still useful because I have on sticker flow. I once answered that question highlight something as red What do I do I answer like invalidate caches and I still get like karma for that answer
So that's why I'm talking about it. That might be help. Well, that's rare. It's rare case. Normally it works The second thing is naming things, right? So you want to write some code and you like some few lines of Python code and you don't want to create a port. You don't want to create a file. What do you do?
What do you know? What what is the way to do it in pi charm? Except console you have Python console. Yeah, but it's full one-liners if you want to write several lines. What do you do? Scratch exactly. So you look for scratch new scratch buffer buffer or you
Yes shortcut for that and you select the language Python and You just write your code and I have here some code and you can Run scratch files as it there are normal files and you can do actually
Like everything it doesn't do it. Okay, we need to print To print and that is postfix completion that I just shown you and You can debug from here this and This is another thing that you might not Be using right now is debugger in pi charm, which I claim
much better than PDB Yeah, and yeah f-strings. Let's try f-strings so it works and
Duplicate line Remove line and see I just showing some shortcuts for actions yeah, and This code is Python code right it's f-strings and Python 3.6 The syntax is highlighted and you see there is a code completion, but it's not unique only for f-strings
actually that universal Machinery inside intelligent products is called language injection and I will show you how to use it It can be used for all languages. For example, you can write something Regex you can write something. I don't know and
Inject language reference Regex and it's highlighted or you can square Table it's already detected. It's injected. It's
On its own or it can be JSON Python 2017
Inject In JSON, yeah, of course, let me try
That's a good question by the way, it doesn't but I know how how to do that the best way to Know it will okay, let's search for that surround selection type and quote embrace. Yeah
I learned something new today. That's great. Yeah and braces as well. No
Yeah, yeah Cool that's cool. So yeah, do we have any time or how much time we have? No, we don't have it's two minutes Okay, then we are done. Thank you very much. I try to show is as much as I could
Thank You Dimitri are there any more questions Hi there. Thanks for the presentation. Um, I was wondering if it's possible to make pycharm consume
Coverage reports that were generated externally because the I know you can run with coverage from within pycharm But I have the coverage report already for my continuous integration for Jenkins or Travis I want pycharm just to use those words rather than generate its own
Yeah In pycharm, you can generate the external coverage report Well, you want to use the already generated coverage report to highlight in the editor. Yes I want the externally generated coverage to appear in the pycharm gutter there is For coverage there is action to open but I guess that's for internal like serialization format
So it won't work for coverage of PI and I know that we have feature requests for that and we at some point We fix that it's counted as a Superword another question
My question is based on the comparison between like suggested code completions in sublime and in pycharm Some pycharm seems to rely on Knowledge about local variables and what types there are probably, you know, what methods they contain and so on whereas Sublime it offers things that you've just typed before anywhere like within the file, which I find
Found very useful as well. Is it possible to achieve that in pycharm? Do you understand what I mean or sorry? I'd sorry. I need to slow down perhaps so in sublime suggested code completions It will like if you start typing something
the first few Characters of something you've typed before anywhere within that file it will suggest that as a completion This doesn't happen in pycharm Like suggested completions are based on say knowledge of like the local variables within a function What types there are like what what what methods they might contain? Do you understand? Yeah. Yeah, if I can understand correctly the question you're saying that in sublime when you start typing
It suggests you are the completion for the like words that you used already. Yeah Pycharm does the same but Pycharm, but what Pycharm does actually is it understands the semantics of your code and it
Provides you not only with just random tokens across the file. Yeah, but it tries to guess what you want to type and if you start typing here it first Suggest you variables and functions and but also you can for example here we'll
Type something. Let's try the name. I Think that this thing will be no Suggest it
It's not in the name space so it doesn't suggest it. Is that correct? So Actually, there are several types of completion in Pycharm. So when you type there is a like pop-up completion that
Tries to know that understands the scope and it's it's very fast and shows what in the scope there is also Completion Let me find an action for that Class name completion that actually is a bit slower, but that goes out of the scope and it
Proposes you all the name that it has in the indexes So it's not only for classes. It's for
We'll help you if I understand correctly Yeah, so you type things they are not in the context It doesn't provide it because those names are not in the context They are in the outer scope then you and just involve this class based class completion controlled space and it goes up to the it goes to the index and goes up in the scope in some sense and
Provides you with all the names, but also it has semantics it won't provide all the all the words There I don't know. I could not invoke that but I'm sure that we have Token based completion. I Will think about that. Thank you for the question. Okay. Thank you
Any other questions? Hi, I like Pycharm's linting but other people in my company use pilot and The interaction between those two is a bit it's very hard to synchronize them. Is there a good way of doing that will there be?
Could you please repeat? Sorry too fast. Yeah, I like the linting that Pycharm has and How it displays the linting errors But other people in my company use pilot and but what is by death?
Sorry what they use Other other people use pilot I don't hear the name. I don't know Not to play Kate but pylint
Sorry, okay pylint. Yeah So obviously you can run pylint from inside Pycharm, but it doesn't integrate the output It gives it doesn't display on the file. Is there any way of doing that or might there be? You want to run pylint from Python, right? Yeah, I'd like to be able to you Yeah, you can do that in some sense by using external
External tools Right, but then the output from pylint is just yeah It's not in line. It will show the output in the tool window if you want to It to be shown as a pet paid for example in the editor Yeah, it's not implemented yet, but we know about that and we want to fix that. Maybe this year
cool We're out of time. So if you want to learn more about Pycharm, please visit Dimitri at Pycharm both Thank you Dimitri. Thank you very much