Skip to content

Commit c0c534a

Browse files
authored
Merge pull request #3 from arionvlad/tooling/development-environment
Configure Python development tooling
2 parents 675e9e8 + 48900d3 commit c0c534a

9 files changed

Lines changed: 60 additions & 25 deletions

File tree

.github/workflows/python.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@ jobs:
1919
with:
2020
python-version: ${{ matrix.python-version }}
2121
- run: python -m pip install --upgrade pip
22-
- run: python -m pip install -e .[test]
23-
- run: python -m pytest
22+
- run: python -m pip install -e ".[dev]"
23+
- run: ruff check .
24+
- run: ruff format --check .
25+
- run: mypy .
26+
- run: pytest
27+

.vscode/extensions.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["ms-python.python", "ms-python.vscode-pylance", "charliermarsh.ruff"]
3+
}

.vscode/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"python.testing.pytestEnabled": true,
3+
"python.testing.unittestEnabled": false,
4+
"python.testing.pytestArgs": ["tests"],
5+
"[python]": {
6+
"editor.defaultFormatter": "charliermarsh.ruff",
7+
"editor.formatOnSave": true,
8+
"editor.codeActionsOnSave": {
9+
"source.fixAll.ruff": "explicit",
10+
"source.organizeImports.ruff": "explicit"
11+
}
12+
}
13+
}

pyproject.toml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,31 @@ dependencies = []
1616
[project.urls]
1717
Repository = "https://github.com/arionvlad/python-apprentice"
1818

19+
[project.optional-dependencies]
20+
dev = [
21+
"mypy",
22+
"pytest",
23+
"ruff",
24+
]
25+
1926
[tool.setuptools.packages.find]
20-
where = ["src"]
27+
where = ["src"]
28+
29+
[tool.ruff]
30+
line-length = 88
31+
target-version = "py311"
32+
33+
[tool.ruff.lint]
34+
select = ["E", "F", "I", "UP"]
35+
36+
[tool.ruff.format]
37+
quote-style = "double"
38+
39+
[tool.mypy]
40+
python_version = "3.11"
41+
strict = true
42+
files = ["src", "tests"]
43+
44+
[tool.pytest.ini_options]
45+
testpaths = ["tests"]
46+
pythonpath = ["src"]

src/python_apprentice/__init__.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
"""Python Apprentice package."""
22

3-
from __future__ import annotations
3+
from .greetings import greet
44

5-
6-
def greet(name: str) -> str:
7-
return f"Hello, {name}!"
8-
9-
10-
from .main import main
11-
12-
__all__ = ["greet", "main"]
5+
__all__ = ["greet"]

src/python_apprentice/greetings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def greet(name: str) -> str:
2+
return f"Hello, {name}!"

src/python_apprentice/main.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
"""Application entrypoint."""
22

3-
from __future__ import annotations
4-
5-
from . import greet
3+
from python_apprentice import greet
64

75

86
def main() -> None:
9-
print(greet("World"))
10-
11-
12-
if __name__ == "__main__":
13-
main()
7+
print(greet("world"))

tests/test_greeting.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from python_apprentice import greet
2+
3+
4+
def test_greet_returns_personalized_message() -> None:
5+
assert greet("Vlad") == "Hello, Vlad!"

tests/test_my_package.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)