Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(python)!: drop python 3.8 support #260

Merged
merged 2 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -32,7 +32,7 @@ jobs:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
python-version: "3.8"
python-version: "3.9"
enable-cache: true
cache-dependency-glob: "uv.lock"
- run: uv sync --group types
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -38,7 +38,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.8
3.9
84 changes: 42 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,6 @@

Identify unused dependencies and avoid a bloated virtual environment.

## 🌀 Migration guide: creosote 2.x to 3.x

<details>
<summary>Expand me to read the guide.</summary>

<br>Creosote was updated to 3.0.0 because the way arguments were supplied has
now changed. This also brings `pyproject.toml` configuration support.

### Argument name change

The argument naming has changed:

| 2.x argument name | 3.x argument name |
| ----------------- | ----------------- |
| `--exclude-deps` | `--exclude-dep` |
| `--paths` | `--path` |
| `--sections` | `--section` |

### Multiple argument values

With creosote 2.x, you were able to provide multiple values following some
arguments, example:

```bash
creosote -p file1.py file2.py
```

With creosote 3.x, you must now provide multiple arguments as a key/value pair:

```bash
creosote -p file1.py -p file2.py
```

This new creosote 3.x behavior applies to the following 3.x CLI arguments:

- `--venv`
- `--exclude-dep`
- `-p` or `--path`
- `-s` or `--section`

</details>

## ⚡️ Quickstart

Install creosote in separate virtual environment, using e.g.
Expand Down Expand Up @@ -274,6 +232,48 @@ Because it makes me happy to see this tool can help others! 🥰
- [Creosote - Identify unused dependencies and avoid a bloated virtual environment](https://www.reddit.com/r/Python/comments/11n717z/creosote_identify_unused_dependencies_and_avoid_a/)
— Reddit

## 🌀 Migration guide: creosote 2.x to 3.x

<details>
<summary>Expand me to read the guide.</summary>

<br>Creosote was updated to 3.0.0 because the way arguments were supplied has
now changed. This also brings `pyproject.toml` configuration support.

### Argument name change

The argument naming has changed:

| 2.x argument name | 3.x argument name |
| ----------------- | ----------------- |
| `--exclude-deps` | `--exclude-dep` |
| `--paths` | `--path` |
| `--sections` | `--section` |

### Multiple argument values

With creosote 2.x, you were able to provide multiple values following some
arguments, example:

```bash
creosote -p file1.py file2.py
```

With creosote 3.x, you must now provide multiple arguments as a key/value pair:

```bash
creosote -p file1.py -p file2.py
```

This new creosote 3.x behavior applies to the following 3.x CLI arguments:

- `--venv`
- `--exclude-dep`
- `-p` or `--path`
- `-s` or `--section`

</details>

## 👩‍🔬 Development/debugging info

### Install in-development builds
Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ name = "creosote"
description = 'Identify unused dependencies and avoid a bloated virtual environment.'
version = "3.2.1"
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.9"
keywords = []
authors = [{ name = "Fredrik Averpil", email = "[email protected]" }]
classifiers = [
# https://pypi.org/classifiers/
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down Expand Up @@ -94,11 +93,11 @@ ignore = []
]

[tool.basedpyright]
pythonVersion = "3.8"
pythonVersion = "3.9"
venvPath = ".venv"

[tool.mypy]
python_version = "3.8"
python_version = "3.9"
strict = true

[[tool.mypy.overrides]]
Expand Down
3 changes: 2 additions & 1 deletion src/creosote/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
from typing import Optional, Sequence
from collections.abc import Sequence
from typing import Optional

from loguru import logger

Expand Down
17 changes: 9 additions & 8 deletions src/creosote/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
import os
import sys
import typing
from collections.abc import Sequence
from dataclasses import dataclass, field
from enum import Enum
from pathlib import Path
from typing import List, Literal, Optional, Sequence, Union
from typing import Literal, Optional, Union

if sys.version_info >= (3, 11):
import tomllib # pyright: ignore[reportUnreachable]
Expand All @@ -27,14 +28,14 @@ class Config:

verbose: bool = False
format: Literal["default", "no-color", "porcelain"] = "default"
paths: List[str] = field(default_factory=lambda: ["src"])
sections: List[str] = field(default_factory=lambda: ["project.dependencies"])
exclude_deps: List[str] = field(default_factory=list)
paths: list[str] = field(default_factory=lambda: ["src"])
sections: list[str] = field(default_factory=lambda: ["project.dependencies"])
exclude_deps: list[str] = field(default_factory=list)
deps_file: str = "pyproject.toml"
venvs: List[str] = field(
venvs: list[str] = field(
default_factory=lambda: [os.environ.get("VIRTUAL_ENV", ".venv")]
)
features: List[str] = field(default_factory=list)
features: list[str] = field(default_factory=list)


class Features(Enum):
Expand All @@ -56,9 +57,9 @@ class CustomAppendAction(argparse.Action):

def __init__( # type: ignore[no-untyped-def]
self,
option_strings: List[str],
option_strings: list[str],
dest: str,
nargs: Optional[List[str]] = None,
nargs: Optional[list[str]] = None,
**kwargs, # pyright: ignore[reportUnknownParameterType, reportMissingParameterType]
):
"""Initialize the action."""
Expand Down
3 changes: 1 addition & 2 deletions src/creosote/formatters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sys
from typing import List

from loguru import logger

Expand Down Expand Up @@ -27,7 +26,7 @@ def configure_logger(verbose: bool, format_: str) -> None:
)


def print_results(unused_dependency_names: List[str], format_: str) -> None:
def print_results(unused_dependency_names: list[str], format_: str) -> None:
if unused_dependency_names:
if format_ == "porcelain":
print("\n".join(unused_dependency_names))
Expand Down
12 changes: 6 additions & 6 deletions src/creosote/models.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import dataclasses
from typing import List, Optional
from typing import Optional


@dataclasses.dataclass
class ImportInfo:
module: List[str]
name: List[str]
module: list[str]
name: list[str]
alias: Optional[str] = None


@dataclasses.dataclass
class DependencyInfo:
name: str # as defined in the dependencies specification file
top_level_import_names: Optional[List[str]] = None
record_import_names: Optional[List[str]] = None
top_level_import_names: Optional[list[str]] = None
record_import_names: Optional[list[str]] = None
canonicalized_dep_name: Optional[str] = None
associated_imports: List[ImportInfo] = dataclasses.field(default_factory=list)
associated_imports: list[ImportInfo] = dataclasses.field(default_factory=list)
Loading
Loading