Skip to content

Commit

Permalink
fix to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
sgmdlt committed Dec 11, 2024
0 parents commit 99baec4
Show file tree
Hide file tree
Showing 12 changed files with 299 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/pyci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Python CI

on:
- push
- pull_request

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
# make depends on uv
- name: Install dependencies
run: |
pip install uv
make install
- name: Run linter and pytest
run: |
make check
- name: Test & publish code coverage
uses: paambaati/codeclimate-action@v9.0.0
if: github.ref_name == 'main'
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageCommand: make test-coverage
debug: true
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.egg-info
__pycache__
dist/
*.pyc
.venv
.coverage
coverage.xml
*_cache/
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
install:
uv sync

run:
uv run hexlet-python-package

test:
uv run pytest

test-coverage:
uv run pytest --cov=hexlet_python_package --cov-report xml

lint:
uv run ruff check

check: test lint

build:
uv build

.PHONY: install test lint selfcheck check build
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# python-package

[![Github Actions Status](https://github.com/hexlet-boilerplates/python-package/workflows/Python%20CI/badge.svg)](https://github.com/hexlet-boilerplates/python-package/actions)
[![Maintainability](https://api.codeclimate.com/v1/badges/df66c0cbbeca7d822f23/maintainability)](https://codeclimate.com/github/hexlet-boilerplates/python-package/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/df66c0cbbeca7d822f23/test_coverage)](https://codeclimate.com/github/hexlet-boilerplates/python-package/test_coverage)

### Links

This project was built using these tools:

| Tool | Description |
|------------------------------------------------------------------------|---------------------------------------------------------|
| [uv](https://docs.astral.sh/uv/) | "An extremely fast Python package and project manager, written in Rust" |
| [Pytest](https://pytest.org) | "A mature full-featured Python testing tool" |
| [ruff](https://docs.astral.sh/ruff/) | "An extremely fast Python linter and code formatter, written in Rust" |

---

### Setup

```bash
make install
```


### Run tests

```bash
make test
```

[![Hexlet Ltd. logo](https://raw.githubusercontent.com/Hexlet/assets/master/images/hexlet_logo128.png)](https://hexlet.io/?utm_source=github&utm_medium=link&utm_campaign=python-package)

This repository is created and maintained by the team and the community of Hexlet, an educational project. [Read more about Hexlet](https://hexlet.io/?utm_source=github&utm_medium=link&utm_campaign=python-package).

See most active contributors on [hexlet-friends](https://friends.hexlet.io/).
Empty file.
2 changes: 2 additions & 0 deletions hexlet_python_package/half.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def half(num):
return num / 2
11 changes: 11 additions & 0 deletions hexlet_python_package/scripts/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import sys

from hexlet_python_package.half import half


def main():
print(half(float(sys.argv[-1])))


if __name__ == "__main__":
main()
26 changes: 26 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[project]
authors = [
{name = "Hexlet team", email = "team@hexlet.io"},
]
requires-python = "<4.0,>=3.12"
name = "python-example-app"
version = "0.1.0"
description = "Example application"
readme = "README.md"

[tool.uv]
dev-dependencies = [
"ruff>=0.7.1",
"pytest>=8.3.3",
"pytest-cov>=5.0.0",
]

[project.scripts]
hexlet-python-package = "hexlet_python_package.scripts.main:main"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["hexlet_python_package"]
9 changes: 9 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
line-length = 80

[lint.per-file-ignores]
# init modules can contain the local imports, logic, unused imports
"__init__.py" = ["F401"]

[lint]
preview = true
select = ["E", "F", "I"]
Empty file added tests/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions tests/test_half.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from hexlet_python_package.half import half


def test_half():
assert half(6) == 3
150 changes: 150 additions & 0 deletions uv.lock

Large diffs are not rendered by default.

0 comments on commit 99baec4

Please sign in to comment.