Debian Codegraph @

.github/CONTRIBUTING.md

raw symbols SCIP
1 # Contributor's guide
2
3 We welcome pull requests from `cmd2` users and seasoned Python developers alike! Follow these steps
4 to contribute:
5
6 1. Find an issue that needs assistance by searching for the
7 [Help Wanted](https://github.com/python-cmd2/cmd2/labels/help%20wanted) tag
8
9 2. Let us know you're working on it by posting a comment on the issue
10
11 3. Follow the [Contribution guidelines](#contribution-guidelines) below to start working on the
12 issue
13
14 Remember to feel free to ask for help by leaving a comment within the Issue.
15
16 Working on your first pull request? You can learn how from the
17 [GitHub Docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request).
18
19 ###### If you've found a bug that is not on the board, [follow these steps](../README.md#found-a-bug).
20
21 ---
22
23 ## Contribution guidelines
24
25 - [Prerequisites](#prerequisites)
26 - [Forking the project](#forking-the-project)
27 - [Creating a branch](#creating-a-branch)
28 - [Setting up for cmd2 development](#setting-up-for-cmd2-development)
29 - [Making changes](#making-changes)
30 - [Code Quality Checks](#code-quality-checks)
31 - [Running the test suite](#running-the-test-suite)
32 - [Squashing your commits](#squashing-your-commits)
33 - [Creating a pull request](#creating-a-pull-request)
34 - [Common steps](#common-steps)
35 - [How we review and merge pull requests](#how-we-review-and-merge-pull-requests)
36 - [How we close stale issues](#how-we-close-stale-issues)
37 - [Next steps](#next-steps)
38 - [Other resources](#other-resources)
39 - [Advice](#advice)
40 - [Developing in an IDE](#developing-in-an-ide)
41 - [Publishing a new release](#publishing-a-new-release)
42
43 ### Prerequisites
44
45 `cmd2` development is heavily based around using [uv](https://github.com/astral-sh/uv) for Python
46 package and project management as well as creating and updating a local Python virtual environment.
47 We also rely on [npm](https://www.npmjs.com/) for installing a few dependencies like
48 [prettier](https://prettier.io/) for formatting non-Python files.
49
50 We have a [Makefile](../Makefile) with commands that make it quick and easy for developers to get
51 everything set up and perform common development tasks.
52
53 Nearly all project configuration, including for dependencies and quality tools is in the
54 [pyproject.toml](../pyproject.toml) file other than for `ruff` which is in
55 [ruff.toml](../ruff.toml).
56
57 > _Updating to the latest releases for all prerequisites via `uv` is recommended_. This can be done
58 > with `uv lock --upgrade` followed by `uv sync`.
59
60 #### Prerequisites to run cmd2 applications
61
62 See the `dependencies` list under the `[project]` heading in [pyproject.toml](../pyproject.toml).
63
64 | Prerequisite | Minimum Version | Purpose |
65 | ------------------------------------------------------------------------- | --------------- | ------------------------------------------------------ |
66 | [prompt-toolkit](https://github.com/prompt-toolkit/python-prompt-toolkit) | `3.0.52` | Replacement for GNU `readline` that is cross-platform |
67 | [python](https://www.python.org/downloads/) | `3.11` | Python programming language |
68 | [pyperclip](https://github.com/asweigart/pyperclip) | `1.8` | Cross-platform clipboard functions |
69 | [rich](https://github.com/Textualize/rich) | `14.3.0` | Add rich text and beautiful formatting in the terminal |
70 | [rich-argparse](https://github.com/hamdanal/rich-argparse) | `1.7.1` | A rich-enabled help formatter for argparse |
71
72 #### Additional prerequisites to build and publish cmd2
73
74 See the `build` list under the `[dependency-groups]` heading in [pyproject.toml](../pyproject.toml)
75 for a list of dependencies needed for building `cmd2`.
76
77 | Prerequisite | Minimum Version | Purpose |
78 | -------------------------------------------------------- | --------------- | -------------------------------- |
79 | [build](https://pypi.org/project/build/) | `1.2.2` | Python build frontend |
80 | [setuptools](https://pypi.org/project/setuptools/) | `72.1.0` | Python package management |
81 | [setuptools-scm](https://github.com/pypa/setuptools-scm) | `8.0.4` | Manage your versions by scm tags |
82
83 > [uv-publish](https://pypi.org/project/uv-publish/) is also needed for publishing releases to PyPI,
84 > but that is something only core maintainers need to worry about.
85
86 #### Additional prerequisites for developing cmd2
87
88 See the `dev` list under the `[dependency-groups]` heading in [pyproject.toml](../pyproject.toml)
89 for a list of dependencies needed for building `cmd2`.
90
91 | Prerequisite | Minimum Version | Purpose |
92 | ------------------------------------------------------- | --------------- | ---------------------------------- |
93 | [codecov](http://doc.pytest.org/en/latest/) | `2.1.13` | Cover coverage reporting |
94 | [mypy](https://mypy-lang.org/) | `1.13.0` | Static type checker |
95 | [pytest](https://docs.pytest.org/en/stable/) | `3.0.6` | Unit and integration tests |
96 | [pytest-cov](http://doc.pytest.org/en/latest/) | `6.0.0` | Pytest code coverage |
97 | [pytest-mock](https://pypi.org/project/pytest-mock/) | `3.14.0` | Pytest mocker fixture |
98 | [mkdocstrings[python]](https://mkdocstrings.github.io/) | `0.27.0` | Zensical plugin for Python AutoDoc |
99 | [ruff](https://github.com/astral-sh/ruff) | `0.7.3` | Fast linter and formatter |
100 | [uv](https://github.com/astral-sh/uv) | `0.5.1` | Python package management |
101 | [Zensical](https://github.com/zensical/zensical) | `0.0.17` | Markdown-based documentation |
102
103 If Python is already installed in your machine, run the following commands to validate the versions:
104
105 ```sh
106 $ python -V
107 $ pip freeze | grep pyperclip
108 ```
109
110 If your versions are lower than the prerequisite versions, you should update.
111
112 If you do not already have Python installed on your machine, we recommend using
113 [uv](https://github.com/astral-sh/uv) for all of your Python needs because it is extremely fast,
114 meets all Python installation and packaging needs, and works on all platforms (Windows, Mac, and
115 Linux). You can install `uv` using instructions at the link above.
116
117 You can then install multiple versions of Python using `uv` like so:
118
119 ```sh
120 uv python install 3.11 3.12 3.13 3.14
121 ```
122
123 ### Forking the project
124
125 #### Setting up your system
126
127 1. Install [Git](https://git-scm.com/) or your favorite Git client. If you aren't comfortable with
128 Git at the command-line, then both [SmartGit](http://www.syntevo.com/smartgit/) and
129 [GitKraken](https://www.gitkraken.com) are excellent cross-platform graphical Git clients.
130 2. (Optional) [Set up an SSH key](https://help.github.com/articles/generating-an-ssh-key/) for
131 GitHub.
132 3. Create a parent projects directory on your system. For this guide, it will be assumed that it is
133 `~/src`.
134
135 #### Forking cmd2
136
137 1. Go to the top-level cmd2 repository: <https://github.com/python-cmd2/cmd2>
138 2. Click the "Fork" button in the upper right hand corner of the interface
139 ([more details here](https://help.github.com/articles/fork-a-repo/))
140 3. After the repository has been forked, you will be taken to your copy of the cmd2 repo at
141 `yourUsername/cmd2`
142
143 #### Cloning your fork
144
145 1. Open a terminal / command line / Bash shell in your projects directory (_e.g.: `~/src/`_)
146 2. Clone your fork of cmd2, making sure to replace `yourUsername` with your GitHub username. This
147 will download the entire cmd2 repo to your projects directory.
148
149 ```sh
150 $ git clone https://github.com/yourUsername/cmd2.git
151 ```
152
153 #### Set up your upstream
154
155 1. Change directory to the new cmd2 directory (`cd cmd2`)
156 2. Add a remote to the official cmd2 repo:
157
158 ```sh
159 $ git remote add upstream https://github.com/python-cmd2/cmd2.git
160 ```
161
162 Congratulations, you now have a local copy of the cmd2 repo!
163
164 #### Maintaining your fork
165
166 Now that you have a copy of your fork, there is work you will need to do to keep it current.
167
168 ##### **Rebasing from upstream**
169
170 Do this prior to every time you create a branch for a PR:
171
172 1. Make sure you are on the `main` branch
173
174 > ```sh
175 > $ git status
176 > On branch main
177 > Your branch is up-to-date with 'origin/main'.
178 > ```
179
180 > If your aren't on `main`, resolve outstanding files and commits and checkout the `main` branch
181
182 > ```sh
183 > $ git checkout main
184 > ```
185
186 2. Do a pull with rebase against `upstream`
187
188 > ```sh
189 > $ git pull --rebase upstream main
190 > ```
191
192 > This will pull down all of the changes to the official mai branch, without making an additional
193 > commit in your local repo.
194
195 3. (_Optional_) Force push your updated main branch to your GitHub fork
196
197 > ```sh
198 > $ git push origin main --force
199 > ```
200
201 > This will overwrite the main branch of your fork.
202
203 ### Creating a branch
204
205 Before you start working, you will need to create a separate branch specific to the issue or feature
206 you're working on. You will push your work to this branch.
207
208 #### Naming your branch
209
210 Name the branch something like `fix/xxx` or `feature/xxx` where `xxx` is a short description of the
211 changes or feature you are attempting to add. For example `fix/script-files` would be a branch where
212 you fix something specific to script files.
213
214 #### Adding your branch
215
216 To create a branch on your local machine (and switch to this branch):
217
218 ```sh
219 $ git checkout -b [name_of_your_new_branch]
220 ```
221
222 and to push to GitHub:
223
224 ```sh
225 $ git push origin [name_of_your_new_branch]
226 ```
227
228 ##### If you need more help with branching, take a look at
229
230 _[this](https://github.com/Kunena/Kunena-Forum/wiki/Create-a-new-branch-with-git-and-manage-branches)_.
231
232 ### Setting up for cmd2 development
233
234 For doing `cmd2` development, it is strongly recommended you create a virtual environment using `uv`
235 by following the instructions in the next section.
236
237 #### Create a new environment for cmd2 using uv
238
239 `cmd2` has support for using [uv](https://github.com/astral-sh/uv) for development.
240
241 `uv` is single tool to replace `pip`, `pip-tools`, `pipx`, `poetry`, `pyenv`, `twine`, `virtualenv`,
242 and more. `cmd2` contains configuration for using `uv` in it's `pyproject.toml` file which makes it
243 extremely easy to set up a `cmd2` development environment using `uv`.
244
245 To create a virtual environment using the latest stable version of Python and install everything
246 needed for `cmd2` development using `uv`, do the following from the root of your cloned `cmd2`
247 repository:
248
249 ```sh
250 make install
251 ```
252
253 This will also install the recommended Git pre-commit hooks for auto-formatting and linting locally.
254
255 To create a new virtualenv, using a specific version of Python you have installed, use the --python
256 VERSION flag, like so:
257
258 ```sh
259 uv venv --python 3.12
260 ```
261
262 Then you can run commands in this isolated virtual environment using `uv` like so:
263
264 ```sh
265 uv run examples/hello_cmd2.py
266 ```
267
268 Alternatively you can activate the virtual environment using the OS-specific command such as this on
269 Linux or macOS:
270
271 ```sh
272 source .venv/bin/activate
273 ```
274
275 Assuming you cloned the repository to `~/src/cmd2` and set up a virtual environment using `uv`,
276 `cmd2` in this venv is in
277 [editable mode](https://pip.pypa.io/en/stable/cli/pip_install/#editable-installs). Changes to the
278 source code are immediately available when the python interpreter imports `cmd2`, there is no need
279 to re-install the module after every change. This command will also install all of the runtime
280 dependencies for `cmd2` and modules used for development of `cmd2`:
281
282 ```sh
283 $ cd ~/src/cmd2
284 $ uv venv
285 ```
286
287 This project uses many python modules for various development tasks, including testing, rendering
288 documentation, and building and distributing releases. These modules can be configured many
289 different ways, which can make it difficult to learn the specific incantations required for each
290 project you're familiar with.
291
292 This project uses [make](<https://en.wikipedia.org/wiki/Make_(software)>) to provide a clean,
293 high-level interface for these development tasks. To see the full list of make commands available:
294
295 ```sh
296 $ make help
297 ```
298
299 You can run multiple make commands in a single invocation, for example::
300
301 ```sh
302 $ make test docs-test
303 ```
304
305 That one command will run all unit and integration tests and also ensure the documentation builds
306 without any warnings.
307
308 If you want to see the details about what any of these commands are doing under the hood, just look
309 at the [Makefile](../Makefile).
310
311 Now you can check if everything is installed and working:
312
313 ```sh
314 $ cd ~src/cmd2
315 $ make check
316 ```
317
318 This will run all auto-formatters, linters, and type checkers to ensure code quality. You should run
319 this every time before committing any code. If this all runs successfully, then your virtual
320 environment is set up and working properly.
321
322 You can also run the example app and see a prompt that says "(Cmd)" running the command:
323
324 ```sh
325 $ uv run examples/getting_started.py
326 ```
327
328 You can type `help` to get help or `quit` to quit. If you see that, then congratulations – you're
329 all set. Otherwise, refer to the cmd2
330 [installation instructions](https://cmd2.readthedocs.io/en/latest/overview/installation.html). There
331 also might be an error in the console of your Bash / terminal / command line that will help identify
332 the problem.
333
334 ### Making changes
335
336 This bit is up to you!
337
338 #### How to find code in the cmd2 codebase to fix/edit
339
340 The cmd2 project directory structure is pretty simple and straightforward. All actual code for cmd2
341 is located underneath the `cmd2` directory. The code to generate the documentation is in the `docs`
342 directory. Unit and integration tests are in the `tests` directory. The `examples` directory
343 contains examples of how to use cmd2. There are various other files in the root directory, but these
344 are primarily related to continuous integration and release deployment.
345
346 #### Changes to the documentation files
347
348 If you made changes to any file in the `/docs` directory, you need to build the Zensical
349 documentation and make sure your changes look good:
350
351 ```sh
352 $ make docs-test
353 ```
354
355 In order to see the changes, use your web browser of choice to open `~/cmd2/build/html/index.html`.
356
357 If you would rather use a webserver to view the documentation, including automatic page refreshes as
358 you edit the files, use:
359
360 ```sh
361 $ make docs
362 ```
363
364 You will be shown the IP address and port number where the documents are now served, usually
365 [http://127.0.0.1:8000/](http://127.0.0.1:8000/).
366
367 ### Code Quality Checks
368
369 You should have idiomatic formatters and linters running in your IDE or at the command line before
370 you commit code. `cmd2` uses [ruff](https://github.com/astral-sh/ruff) as part of its continuous
371 integration (CI) process for both linting and auto-formatting of Python code. It also uses
372 [prettier](https://prettier.io/) for auto-formatting other file types and
373 [mypy](https://mypy-lang.org/) for doing static type checking of Python code based on type
374 annotations.
375
376 > Please do not ignore any linting errors in code you write or modify, as they are meant to **help**
377 > you and to ensure a clean and simple code base. Don't worry about linting errors in code you don't
378 > touch though - cleaning up the legacy code is a work in progress.
379
380 You can quickly run all code quality stuff in one fell swoop using:
381
382 ```sh
383 make check
384 ```
385
386 #### Python Formatting
387
388 To check if Python formatting is correct:
389
390 ```sh
391 make format
392 ```
393
394 NOTE: This will automatically fix the formatting, so just run it twice and it should be good.
395
396 #### Linting
397
398 To run the Python linter:
399
400 ```shell
401 make lint
402 ```
403
404 #### Static Type Checking
405
406 ```shell
407 make typecheck
408 ```
409
410 ### Running the test suite
411
412 When you're ready to share your code, run the test suite:
413
414 ```sh
415 $ cd ~/cmd2
416 $ make test
417 ```
418
419 and ensure all tests pass.
420
421 Running the test suite also calculates test code coverage. A summary of coverage is shown on the
422 screen. A full report is available in `~/cmd2/htmlcov/index.html`.
423
424 ### Squashing your commits
425
426 While squashing your commits is best practice, don't worry about it. We do this automatically when
427 we merge in Pull Requests (PRs).
428
429 If you want to understand how to do this manually, see
430 [this article](http://forum.freecodecamp.com/t/how-to-squash-multiple-commits-into-one-with-git/13231).
431
432 ### Creating a pull request
433
434 #### What is a pull request?
435
436 A pull request (PR) is a method of submitting proposed changes to the cmd2 repo (or any repo, for
437 that matter). You will make changes to copies of the files which make up cmd2 in a personal fork,
438 then apply to have them accepted by cmd2 proper.
439
440 #### Need help?
441
442 GitHub has a good guide on how to contribute to open source
443 [here](https://opensource.guide/how-to-contribute/).
444
445 #### Important: ALWAYS EDIT ON A BRANCH
446
447 If you take away only one thing from this document, it should be this: Never, **EVER** make edits to
448 the `main` branch. ALWAYS make a new branch BEFORE you edit files. This is critical, because if your
449 PR is not accepted, your copy of main will be forever sullied and the only way to fix it is to
450 delete your fork and re-fork.
451
452 #### Methods
453
454 There are two methods of creating a pull request for cmd2:
455
456 - Editing files on a local clone (recommended)
457 - Editing files via the GitHub Interface
458
459 ##### Method 1: Editing via your local fork _(recommended)_
460
461 This is the recommended method. Read about
462 [how to set up and maintain a local instance of cmd2](#maintaining-your-fork).
463
464 1. Perform the maintenance step of rebasing `main`
465 2. Ensure you're on the `main` branch using `git status`:
466
467 ```sh
468 $ git status
469 On branch main
470 Your branch is up-to-date with 'origin/main'.
471
472 nothing to commit, working directory clean
473 ```
474
475 1. If you're not on main or your working directory is not clean, resolve any outstanding
476 files/commits and checkout main `git checkout main`
477
478 2. Create a branch off of `main` with git: `git checkout -B branch/name-here` **Note:** Branch
479 naming is important. Use a name like `fix/short-fix-description` or
480 `feature/short-feature-description`. Review the
481 [Contribution Guidelines](#contribution-guidelines) for more detail.
482
483 3. Edit your file(s) locally with the editor of your choice
484
485 4. Check your `git status` to see unstaged files
486
487 5. Add your edited files: `git add path/to/filename.ext` You can also do: `git add .` to add all
488 unstaged files. Take care, though, because you can accidentally add files you don't want added.
489 Review your `git status` first.
490
491 6. Commit your edits: `git commit -m "Brief description of commit"`. Do not add the issue number in
492 the commit message.
493
494 7. Squash your commits, if there are more than one
495
496 8. Push your commits to your GitHub Fork: `git push -u origin branch/name-here`
497
498 9. Go to [Common steps](#common-steps)
499
500 ##### Method 2: Editing via the GitHub interface
501
502 Note: Editing via the GitHub Interface is not recommended, since it is not possible to update your
503 fork via GitHub's interface without deleting and recreating your fork.
504
505 If you really want to go this route (which isn't recommended), you can Google for more information
506 on how to do it.
507
508 ### Common steps
509
510 1. Once the edits have been committed, you will be prompted to create a pull request on your fork's
511 GitHub page
512
513 2. By default, all pull requests should be against the cmd2 main repo, `main` branch
514
515 3. Submit a pull request from your branch to cmd2's `main` branch
516
517 4. The title (also called the subject) of your PR should be descriptive of your changes and
518 succinctly indicate what is being fixed
519 - **Do not add the issue number in the PR title or commit message**
520
521 - Examples: `Add test cases for Unicode support`; `Correct typo in overview documentation`
522
523 5. In the body of your PR include a more detailed summary of the changes you made and why
524 - If the PR is meant to fix an existing bug/issue, then, at the end of your PR's description,
525 append the keyword `closes` and #xxxx (where xxxx is the issue number). Example:
526 `closes #1337`. This tells GitHub to close the existing issue if the PR is merged.
527
528 6. Indicate what local testing you have done (e.g. what OS and version(s) of Python did you run the
529 unit test suite with)
530
531 7. Creating the PR causes our continuous integration (CI) systems to automatically run all of the
532 unit tests on all supported OSes and all supported versions of Python. You should watch your PR
533 to make sure that all unit tests pass on every version of Python for each of Linux, Windows, and
534 macOS.
535
536 8. If any unit tests fail, you should look at the details and fix the failures. You can then push
537 the fix to the same branch in your fork. The PR will automatically get updated and the CI system
538 will automatically run all of the unit tests again.
539
540 ### How we review and merge pull requests
541
542 cmd2 has a team of volunteer Maintainers. These Maintainers routinely go through open pull requests
543 in a process called [Quality Assurance](https://en.wikipedia.org/wiki/Quality_assurance) (QA). We
544 use [GitHub Actions](https://github.com/features/actions) to automatically run all of the unit tests
545 on multiple operating systems and versions of Python and to also run the code quality checks on at
546 least one version of Python.
547
548 1. If your changes can merge without conflicts and all unit tests pass for all OSes and supported
549 versions of Python, then your pull request (PR) will have a big green checkbox which says
550 something like "All Checks Passed" next to it. If this is not the case, there will be a link you
551 can click on to get details regarding what the problem is. It is your responsibility to make sure
552 all unit tests are passing. Generally a Maintainer will not QA a pull request unless it can merge
553 without conflicts and all unit tests pass on all supported platforms.
554
555 2. If a Maintainer QA's a pull request and confirms that the new code does what it is supposed to do
556 without seeming to introduce any new bugs, and doesn't present any backward compatibility issues,
557 they will merge the pull request.
558
559 If you would like to apply to join our Maintainer team, message
560 [@tleonhardt](https://github.com/tleonhardt) with links to 5 of your pull requests that have been
561 accepted.
562
563 ### How we close stale issues
564
565 We will close any issues that have been inactive for more than 60 days or pull requests that have
566 been inactive for more than 30 days, except those that match any of the following criteria:
567
568 - bugs that are confirmed
569 - pull requests that are waiting on other pull requests to be merged
570 - features that are part of a cmd2 GitHub Milestone or Project
571
572 ### Next steps
573
574 #### If your PR is accepted
575
576 Once your PR is accepted, you may delete the branch you created to submit it. This keeps your
577 working fork clean.
578
579 You can do this with a press of a button on the GitHub PR interface. You can delete the local copy
580 of the branch with: `git branch -D branch/to-delete-name`
581
582 #### If your PR is rejected
583
584 Don't despair! You should receive solid feedback from the Maintainers as to why it was rejected and
585 what changes are needed.
586
587 Many pull requests, especially first pull requests, require correction or updating. If you have used
588 the GitHub interface to create your PR, you will need to close your PR, create a new branch, and
589 re-submit.
590
591 If you have a local copy of the repo, you can make the requested changes and amend your commit with:
592 `git commit --amend` This will update your existing commit. When you push it to your fork you will
593 need to do a force push to overwrite your old commit: `git push --force`
594
595 Be sure to post in the PR conversation that you have made the requested changes.
596
597 ### Other resources
598
599 - [PEP 8 Style Guide for Python Code](https://www.python.org/dev/peps/pep-0008/)
600
601 - [Searching for your issue on GitHub](https://help.github.com/articles/searching-issues/)
602
603 - [Creating a new GitHub issue](https://help.github.com/articles/creating-an-issue/)
604
605 ### Advice
606
607 Here is some advice regarding what makes a good pull request (PR) from the perspective of the cmd2
608 maintainers:
609
610 - Multiple smaller PRs divided by topic are better than a single large PR containing a bunch of
611 unrelated changes
612 - Maintaining backward compatibility is important
613 - Good unit/functional tests are very important
614 - Accurate documentation is also important
615 - Adding new features is of the lowest importance, behind bug fixes, unit test
616 additions/improvements, code cleanup, and documentation
617 - It's best to create a dedicated branch for a PR, use it only for that PR, and delete it once the
618 PR has been merged
619 - It's good if the branch name is related to the PR contents, even if it's just "fix123" or
620 "add_more_tests"
621 - Code coverage of the unit tests matters, so try not to decrease it
622 - Think twice before adding dependencies to third-party libraries (outside of the Python standard
623 library) because it could affect a lot of users
624
625 ### Developing in an IDE
626
627 We recommend using [Visual Studio Code](https://code.visualstudio.com) with the
628 [Python extension](https://code.visualstudio.com/docs/languages/python) and its
629 [Integrated Terminal](https://code.visualstudio.com/docs/python/debugging) debugger for debugging
630 since it has excellent support for debugging console applications.
631
632 [PyCharm](https://www.jetbrains.com/pycharm/) is also quite good and has very nice
633 [code inspection](https://www.jetbrains.com/help/pycharm/code-inspection.html) capabilities.
634
635 #### PyCharm Settings
636
637 One of the best things about **PyCharm** is that it "just works" with essentially no configuration
638 tweaks required. The default out-of-the-box experience is excellent.
639
640 The one plugin we consider essential for PyCharm is
641 [RyeCharm](https://plugins.jetbrains.com/plugin/25230-ryecharm). `RyeCharm` is an all-in-one PyCharm
642 plugin for [Astral](https://astral.sh/)-backed Python tools: [uv](https://github.com/astral-sh/uv),
643 [Ruff](https://github.com/astral-sh/ruff), and [ty](https://github.com/astral-sh/ty). NOTE: `ty`
644 support is provisional as that new type checker is in early alpha development.
645
646 #### VSCode Settings
647
648 While **VSCode** is a phenomenal IDE for developing in Python, the out-of-the-box experience leaves
649 a lot to be desired. You will need to install a number of extensions and tweak the default
650 configuration for many of them in order to get an optimal developer experience.
651
652 Recommended VSCode extensions:
653
654 - [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python) - Python language
655 support with extension access points for IntelliSense (Pylance), Debugging (Python Debugger),
656 linting, formatting, etc.
657 - [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) - Code
658 formatter for Markdown and YAML files
659 - [GitLens](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens) - Supercharges Git
660 support in VSCode
661 - [YAML](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) - YAML language
662 support
663 - [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) -
664 Spell checker for source code
665 - [Markdown All in One](https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one) -
666 All you need to write Markdown (keyboard shortcuts, table of contents, auto preview and more)
667 - [Makefile Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools) -
668 Provide makefile support in VS Code
669 - [Even Better TOML](https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml) -
670 Fully-featured TOML support
671 - [Markdown Preview Mermaid Support](https://marketplace.visualstudio.com/items?itemName=bierner.markdown-mermaid) -
672 Adds Mermaid diagram and flowchart support to VS Code's builtin markdown preview
673 - [Ruff](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) - Support for the
674 Ruff linter and formatter
675
676 Depending on what file types you are editing, you may only need a subset of those extensions.
677
678 Here is an example of what your `User Settings JSON` file in VSCode might look like for a good
679 experience, take it as a starting point and tweak as you see fit
680
681 ```json
682 {
683 "[css]": {
684 "editor.defaultFormatter": "esbenp.prettier-vscode"
685 },
686 "editor.formatOnSave": true,
687 "editor.largeFileOptimizations": false,
688 "editor.renderWhitespace": "trailing",
689 "git.blame.editorDecoration.enabled": false,
690 "git.openRepositoryInParentFolders": "always",
691 "gitlens.telemetry.enabled": false,
692 "[html]": {
693 "editor.defaultFormatter": "esbenp.prettier-vscode"
694 },
695 "[json]": {
696 "editor.defaultFormatter": "esbenp.prettier-vscode"
697 },
698 "[markdown]": {
699 "editor.defaultFormatter": "esbenp.prettier-vscode",
700 "editor.formatOnSave": true,
701 "editor.formatOnPaste": true
702 },
703 "python.analysis.ignore": ["*"],
704 "python.terminal.shellIntegration.enabled": true,
705 "[python]": {
706 "editor.formatOnSave": true,
707 "editor.defaultFormatter": "charliermarsh.ruff",
708 "editor.codeActionsOnSave": {
709 "source.fixAll": "explicit",
710 "source.organizeImports": "explicit"
711 }
712 },
713 "redhat.telemetry.enabled": false,
714 "ruff.lineLength": 127,
715 "security.workspace.trust.untrustedFiles": "open",
716 "telemetry.telemetryLevel": "off",
717 "[toml]": {
718 "editor.defaultFormatter": "esbenp.prettier-vscode",
719 "editor.formatOnSave": true
720 },
721 "yaml.schemas": {
722 "https://squidfunk.github.io/mkdocs-material/schema.json": "mkdocs.yml"
723 },
724 "yaml.customTags": [
725 "!ENV scalar",
726 "!ENV sequence",
727 "!relative scalar",
728 "tag:yaml.org,2002:python/name:material.extensions.emoji.to_svg",
729 "tag:yaml.org,2002:python/name:material.extensions.emoji.twemoji",
730 "tag:yaml.org,2002:python/name:pymdownx.superfences.fence_code_format",
731 "tag:yaml.org,2002:python/object/apply:pymdownx.slugs.slugify mapping"
732 ],
733 "[yaml]": {
734 "editor.defaultFormatter": "esbenp.prettier-vscode"
735 }
736 }
737 ```
738
739 ## Branching Strategy and Semantic Versioning
740
741 Starting with version 1.0.0, `cmd2` has adopted [Semantic Versioning](https://semver.org).
742
743 ### Semantic Versioning Summary
744
745 Given a version number `MAJOR`.`MINOR`.`PATCH`, increment the:
746
747 - `MAJOR` version when you make incompatible API changes,
748 - `MINOR` version when you add functionality in a backwards compatible manner, and
749 - `PATCH` version when you make backwards compatible bug fixes.
750
751 ### Branching Strategy
752
753 We use the **main** branch for the upcoming `PATCH` release - i.e. if the current version of `cmd2`
754 is 1.0.2, then the **main** branch contains code which is planned for release in 1.0.3.
755
756 If work needs to be done for a `MAJOR` or `MINOR` release when we anticipate there will be a `PATCH`
757 release in-between, then a branch should be created named for the appropriate version number for the
758 work, e.g. if the current release of `cmd2` is 1.0.2 and a backwards-incompatible change needs to be
759 committed for an upcoming `MAJOR` release, then this work should be committed to a **2.0.0** branch
760 until such a time as we are ready to release version 2.0.0.
761
762 Following this strategy, releases are always done from the **main** branch and `MAJOR` or `MINOR`
763 branches are merged to **main** immediately prior to doing a release. Once merged to **main**, the
764 other branches can be deleted. All releases are tagged so that they can be reproduced if necessary.
765
766 ## Publishing a new release
767
768 Since 0.9.2, the process of publishing a new release of `cmd2` to [PyPi](https://pypi.org/) has been
769 mostly automated. The manual steps are all git operations. Here's the checklist:
770
771 1. Make sure you're on the proper branch (almost always **main**)
772 1. Make sure all the unit tests pass with `make test`
773 1. Make sure latest year in `LICENSE` matches current year
774 1. Make sure `CHANGELOG.md` describes the version and has the correct release date
775 1. Add a git tag representing the version number using `make tag TAG=x.y.z`
776 - Where x, y, and z are all small non-negative integers
777 1. (Optional) Run `make publish-test` to clean, build, and upload a new release to
778 [Test PyPi](https://test.pypi.org)
779 1. Run `make publish` to clean, build, and upload a new release to [PyPi](https://pypi.org/)
780
781 ## Acknowledgement
782
783 Thanks to the good folks at [freeCodeCamp](https://github.com/freeCodeCamp/freeCodeCamp) for
784 creating an excellent `CONTRIBUTING` file which we have borrowed heavily from.