carpentries-incubator / python-intermediate-development-earth-sciences

Intermediate Research Software Development Skills In Python for Earth Sciences
https://carpentries-incubator.github.io/python-intermediate-development-earth-sciences/
Other
4 stars 3 forks source link

Test course code in VS Code #7

Closed AnnAnnFryingPan closed 7 months ago

AnnAnnFryingPan commented 9 months ago

For installation of VS Code, see Current 'Extras' -> 'Additional Material' -> 'Using Microsoft Visual Studio Code'

This page also has good instructions on installing extensions, e.g. Python; and configuring a Virtual Environment.

... also in Running Tests, and a very brief Section (a sentence) on running in debug.

AnnAnnFryingPan commented 8 months ago

Have started using VS Code to go through the course notes: (Still not sure on full range of options, but have at least got things working.)

Steps so far:

Open a project by clicking on 'File' then 'Open folder'.

Added 2 Python related extensions ('Python' and 'Python Environment Manager'):

Image

Select the environment

Using VS Code default environment selection

Click on the environment, in the bottom right-hand-side status bar and then select the correct environment from the drop-down list from the top edit box.

Image

using 'Python Environment Manager'

Image

List available and selected environments (using the 'Python Environment Manager' extension):

Image

Import package (The magnifying glass symbol means 'import package' :/ !!

Image

Find Files

Image

group the results

Image

Running the application (4 methods)

using menu

Image

Using top-right run button

Image

Right-click on file

Image

Using the Run and Debug tabl

Image

AnnAnnFryingPan commented 8 months ago

Will work on debugging next

AnnAnnFryingPan commented 8 months ago

Version Control

Image

AnnAnnFryingPan commented 8 months ago

Pep8

Install autopep8 (one example, other formatter extensions exist)

Image

AnnAnnFryingPan commented 8 months ago

Indentation: File -> Preferences -> Settings Look for 'Editor:Tab Size' (default =4)and 'Editor: Insert Spaces' (default =True)

AnnAnnFryingPan commented 8 months ago

Folding: Use the ^ and v arrows by each relevant line, to fold/unfold code

Image

AnnAnnFryingPan commented 8 months ago

File Encoding

Image

AnnAnnFryingPan commented 7 months ago

Showing Whitespace:

File -> Preferences -> Settings Search on 'Render Whitespace' Select 'all' from drop-down editbox menu.

AnnAnnFryingPan commented 7 months ago

Linters

Pylint extension

Image

AnnAnnFryingPan commented 7 months ago

Running Tests in VS Code

See the 'Extras' -> 'Additional Material' -> 'Using Microsoft Visual Studio Code' section of the course notes.

Click on the Testing tab

Image

Or use the Ctl+Shift+P to get the Command Palette then look for 'Python: Configure Tests' and it brings up an edit box where you can point the test compiler to the correct test scripts.

VS Code Docs:

Image

Screenshot of using Command Palatte:

Image

Image