-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated walkthrough for coding assistant
- Loading branch information
Tim Gilboy
authored and
Tim Gilboy
committed
Sep 26, 2023
1 parent
6d62611
commit 4c0b1a2
Showing
7 changed files
with
54 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,16 @@ After those 14 days you can choose to upgrade to Pro or you can keep using Sourc | |
|
||
Sourcery is free to use for students and educators on open source and closed source projects. Email us at [[email protected]](mailto:[email protected]) and we'll get you set up with a free plan. | ||
|
||
### Login | ||
### Log In | ||
|
||
After [signing up](https://sourcery.ai/signup/?utm_source=VS-Code), login by | ||
After [signing up](https://sourcery.ai/signup/?utm_source=VS-Code), log in by | ||
opening the command palette (Ctrl/Cmd+Shift+P) and executing the | ||
`Sourcery: Login` command. | ||
`Sourcery: Login` command. Or open the Sourcery sidebar (click our hexagonal logo) and click the log in button. | ||
|
||
![Logging in with Sourcery](Sourcery_Login.gif) | ||
|
||
### Opting Into Sourcery's Coding Assistant | ||
|
||
There are two main ways you can use Sourcery as a pair programmer. One is through our rules-based in-line suggestions that run fully locally and that you'll see appear in your code. The other is through our Coding Assistant which you can ask questions to, can write new code or update your existing code, and more. The Coding Assistant relies on third party large language models and you need to opt into using it before you can start. | ||
|
||
To opt into use the Coding Assistant, open the Sourcery sidebar, and click the Opt In button. If you choose not to opt in, you can still use the rules-based suggestions from Sourcery fully locally |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,28 @@ | ||
## Finding Your First Refactoring | ||
## Using Sourcery as Your Pair Programmer | ||
|
||
Sourcery continually checks your code and looks for opportunities to refactor it | ||
to make it clearer, cleaner, and easier to work with. In your IDE, Sourcery will | ||
underline or highlight any section of code where it can make a refactoring. | ||
Sourcery works in 2 ways: | ||
1. Gives you instant suggestions for improvements and refactorings to your Python, JavaScript, and TypeScript code. | ||
2. Acts as an AI powered pair programmer allowing you to ask it questions, write new code, and interact with existing code | ||
|
||
Let's take a look at how you can use interact with it in VS Code | ||
|
||
### In the tutorial | ||
|
||
Once you open the tutorial you should see this example: | ||
|
||
```python | ||
def refactoring_example(spellbook): | ||
result = [] | ||
for spell in spellbook: | ||
if spell.is_awesome: | ||
result.append(spell) | ||
return result | ||
def days_between_dates(date1, date2): | ||
d1 = datetime.datetime.strptime(date1, '%Y-%m-%d').date() | ||
d2 = datetime.datetime.strptime(date2, '%Y-%m-%d').date() | ||
delta = d2 - d1 | ||
return delta.days | ||
``` | ||
|
||
You should see Sourcery immediately highlight the `result = []` line with a | ||
refactoring suggestion. | ||
|
||
Hover your mouse over the underlined section to see a description of the change | ||
and a diff of Sourcery's refactoring. | ||
Above the function you'll see a few commands - these are Code Lenses that you can use to interact with Sourcery. Try clicking the "Ask Sourcery" Code Lens and asking it to update the code to use `dateutil`. The answer will appear in the Sourcery sidebar chat. | ||
|
||
To accept one of Sourcery's changes, bring up the code actions/quick fix menu, | ||
and choose to apply the changes. Or you can click on the lightbulb icon to apply | ||
the changes. | ||
![Sourcery updating code](Ask_Sourcery.gif) | ||
|
||
![Accepting Changes In VS Code](Sourcery_3_Ways_to_Refactor_VS_Code.gif) | ||
### More ways Sourcery can help | ||
|
||
You can also bring up all of the changes Sourcery is suggesting to your open | ||
files by opening up the Problems window. | ||
Sourcery can interact with your code in a number of other ways. On the same function try clicking the `Generate Docstrings`, `Generate Tests`, and `Explain Code`Code Lenses. | ||
|