1
+ # Welcome to Sourcery! We're here to be your pair programmer anytime you're
2
+ # working in VS Code.
1
3
2
- # Welcome to Sourcery! We're here to be your pair programmer
3
- # anytime you're working in VS Code.
4
-
5
- # To get started log into your Sourcery account. Click on
6
- # the Sourcery logo (the hexagon) on your VS Code sidebar
7
- # and click the button to log in.
8
-
9
- # Or, open the command palette (Ctrl/Cmd+Shift+P) and
10
- # execute `Sourcery: Login`.
4
+ # To get started log into your Sourcery account. Click on the Sourcery logo
5
+ # (the hexagon) on your VS Code sidebar and click the login button, or open
6
+ # the command palette (Ctrl/Cmd+Shift+P) and execute `Sourcery: Login`.
11
7
12
8
# Sourcery works in 2 ways:
13
- # 1. Gives you instant suggestions for improvements and
14
- # refactorings to your Python, JavaScript, and TypeScript
15
- # code. All of this runs fully locally.
16
- # 2. Acts as an AI powered pair programmer allowing you to ask it
17
- # questions, write new code, and interact with existing code. This
18
- # piece of Sourcery does not run locally.
19
-
20
- # To start using the pair programmer section of Sourcery,
21
- # click the Sourcery sidebar option and click the Opt In button.
22
-
23
- # Now you can start asking Sourcery questions or asking it
24
- # to interact with sections of your code. Let's take a look
25
- # at a few examples:
26
-
27
- # Above each function you'll see a few commands - these are
28
- # Code Lenses that you can use to interact with Sourcery.
29
- # Try clicking the "Ask Sourcery" Code Lens and asking it to
30
- # update the code to use `dateutil`. The answer will appear in
31
- # the Sourcery sidebar chat.
32
-
9
+ # 1. A cloud-based AI powered coding assistant allowing you to ask it
10
+ # questions, write new code, and interact with existing code. To get
11
+ # started opt in via the Sourcery sidebar.
12
+ # 2. Local analysis to give you instant suggestions for improving your
13
+ # Python, JavaScript, and TypeScript code.
33
14
34
15
def days_between_dates (date1 , date2 ):
35
16
d1 = datetime .datetime .strptime (date1 , '%Y-%m-%d' ).date ()
36
17
d2 = datetime .datetime .strptime (date2 , '%Y-%m-%d' ).date ()
37
18
delta = d2 - d1
38
19
return delta .days
39
20
40
- # With the Ask Sourcery command or the chat in the sidebar you
41
- # can ask Sourcery questions, have it write new code for you, or
42
- # update existing code.
21
+ # Let's start with the coding assistant:
22
+ # Above each function you'll see a few commands - these are Code Lenses that
23
+ # you can use to interact with Sourcery. Try clicking on "Ask Sourcery" and
24
+ # asking it to update the code to use `dateutil`. The answer will appear in
25
+ # the Sourcery sidebar chat.
43
26
44
- # Sourcery has a series of built in "recipes" you can quickly use
45
- # to interact with sections of code.
27
+ # With the Ask Sourcery command or the chat in the sidebar you can ask Sourcery
28
+ # questions, have it write new code for you, or update existing code.
46
29
30
+ # Sourcery also has a series of "recipes" to do different things with code.
47
31
# Try clicking the Generate Docstrings lens above this next function:
48
32
49
33
def calculate_weighted_moving_average (prices , weights ):
@@ -63,13 +47,12 @@ def calculate_weighted_moving_average(prices, weights):
63
47
64
48
return wma
65
49
66
- # Now try clicking Generate Tests or Explain Code for the
67
- # same function!
50
+ # Now try clicking Generate Tests or Explain Code for the same function!
68
51
69
- # There are also recipes for Optimizing and Simplifying Code.
70
- # You can access these by clicking Ask Sourcery and choosing them
71
- # from the dropdown or by selecting a section of code and clicking
72
- # the recipe button in the sidebar.
52
+ # There are also recipes for Optimizing Performance and Simplifying Code.
53
+ # You can access these by clicking Ask Sourcery and choosing them from the
54
+ # dropdown or by selecting a section of code and clicking the recipe button
55
+ # in the sidebar.
73
56
74
57
# In your code you'll also see sections start to get underlined.
75
58
# This means Sourcery has a suggestion to improve it.
0 commit comments