Skip to content

Commit

Permalink
add extensions and update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
blefnk committed Mar 25, 2024
1 parent 876ddcc commit 68db541
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"davidanson.vscode-markdownlint",
"yzhang.markdown-all-in-one",
"ms-python.python",
"ms-azuretools.vscode-docker"
]
}
24 changes: 24 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Remote Attach",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}/backend",
"remoteRoot": "."
}
],
"justMyCode": true
}
]
}
30 changes: 30 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.associations": {
"*.ignore": "plaintext",
"*.txt": "plaintext"
},
"editor.tabSize": 2,
"[markdown]": {
"editor.defaultFormatter": "DavidAnson.vscode-markdownlint"
},
"markdownlint.config": {
"MD033": {
"allowed_elements": [
"a",
"code",
"details",
"h3",
"img",
"li",
"ol",
"p",
"pre",
"strong",
"summary",
"ul"
]
}
},
}
66 changes: 62 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ python -m venv C:\B\A\python\venv\main
python -m venv ~/Desktop/B/A/python/venv/main
```

**3. Configure workspace:**

Then open project in VSCode > Ctrl+Shift+P > Terminal: Create New Terminal

**Windows:**
Expand All @@ -54,15 +56,71 @@ C:\B\A\python\venv\main\Scripts\activate.ps1 # Or use .bat when CMD
source ~/Desktop/B/A/python/venv/main/bin/activate
```

**3. Install dependencies:**
**4. Install dependencies:**

The project already has many pre-selected good packages, so you can easily get started, or remove unused packages whenever you want.

<details>
<summary>💡 How to remove unused packages?</summary>

<p>Here are the most common and effective ways to remove unused packages from the <code>requirements.txt</code> file:</p>
<h3>1. Manual Review and Editing:</h3>
<ul>
<li><strong>Best for small projects:</strong> If you already have a relatively short <code>requirements.txt</code> file, you can often manually go through it and identify packages that are no longer actively used in your code.</li>
<li><strong>Time-consuming for larger projects:</strong> This becomes less practical as your project and the list of dependencies grow.</li>
</ul>
<h3>2. Automated Tools:</h3>
<p>These tools analyze your project's code to help determine unused dependencies. Here are some popular options:</p>
<ul>
<li><strong>pip-autoremove:</strong>
<ul>
<li><strong>Install:</strong> <code>pip install pip-autoremove</code></li>
<li><strong>Usage:</strong> <code>pip-autoremove requirements.txt -o requirements.txt</code> (This overwrites your original file)</li>
</ul>
</li>
<li><strong>pipdeptree (with reverse flag):</strong>
<ul>
<li><strong>Install:</strong> <code>pip install pipdeptree</code></li>
<li><strong>Usage:</strong></li>
<li><pre><code>pipdeptree -r &gt; possible_unused.txt # Creates a list of possible unused packages
# Manually review possible_unused.txt and edit requirements.txt
</code></pre></li>
</ul>
</li>
<li><strong>Other Tools:</strong>
<ul>
<li><code>pip-unused</code>: A simple command-line tool.</li>
<li>There may be similar plugins for your IDE or code editor.</li>
</ul>
</li>
</ul>
<h3>Important Considerations:</h3>
<ul>
<li><strong>Caution:</strong> Automated tools can be helpful but they might not be 100% accurate. It's always best to double-check and test your project after removing packages from <code>requirements.txt</code>.</li>
<li><strong>Version Conflicts:</strong> Sometimes packages might remain indirectly necessary due to dependencies of other required packages. Be mindful of complex dependencies when removing packages.</li>
</ul>
<h3>Workflow Example (Using pip-autoremove):</h3>
<ol>
<li><strong>Install pip-autoremove:</strong>
<pre><code>pip install pip-autoremove
</code></pre></li>
<li><strong>Create a backup (optional, but recommended):</strong>
<pre><code>cp requirements.txt requirements.txt.bak
</code></pre></li>
<li><strong>Remove unused packages:</strong>
<pre><code>pip-autoremove requirements.txt -o requirements.txt
</code></pre></li>
<li><strong>Review Changes:</strong> Check the updated <code>requirements.txt</code> to make sure the automated tool didn't remove anything essential.</li>
<li><strong>Test Thoroughly:</strong> Run your project's tests or experiment with it manually to ensure everything still works as expected.</li>
</ol>

</details>

```bash
cd backend && pip install -r requirements.txt
```

### Development

**4. Start the development server:**
**5. Start the development server:**

```bash
uvicorn main:app --reload
Expand Down

0 comments on commit 68db541

Please sign in to comment.