Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Created a new project using `hatch new`. Added linting with `black`
and `ruff` and typing with `mypy`. Created a placeholder for the
AppSignal CLI command.
  • Loading branch information
unflxw committed Mar 13, 2023
0 parents commit f7af937
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.mypy_cache
/.pytest_cache
/.ruff_cache
__pycache__
/dist
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python 3.11.2
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# AppSignal Python

[![PyPI - Version](https://img.shields.io/pypi/v/appsignal-python.svg)](https://pypi.org/project/appsignal-python)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/appsignal-python.svg)](https://pypi.org/project/appsignal-python)

-----

**Table of Contents**

- [Installation](#installation)
- [License](#license)

## Installation

```console
pip install appsignal
```

## Development

AppSignal for Python uses [Hatch](https://hatch.pypa.io/latest/) to manage dependencies, packaging and development environments.

```sh
pip install hatch
```

### Linting and type checking

```sh
hatch run lint:all

hatch run lint:fmt # auto-formatting only
hatch run lint:style # style checking only
hatch run lint:typing # type checking only
```

### Running tests

```sh
hatch run test:pytest
```

### Running the CLI command

```sh
hatch shell
appsignal
```
96 changes: 96 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "appsignal"
description = 'The AppSignal integration for the Python programming language'
readme = "README.md"
requires-python = ">=3.7"
keywords = []
authors = [
{ name = "Tom de Bruijn", email = "[email protected]" },
{ name = "Noemi Lapresta", email = "[email protected]" },
]
classifiers = [
# Python versions
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
# Application version
"Development Status :: 3 - Alpha",
# Remove this to allow publishing
"Private :: Do Not Upload"
]
dependencies = []
dynamic = ["version"]

[project.urls]
Documentation = "https://github.com/appsignal/appsignal-python#readme"
Issues = "https://github.com/appsignal/appsignal-python/issues"
Source = "https://github.com/appsignal/appsignal-python"

[project.scripts]
appsignal = "appsignal.cli:run"

[tool.hatch.version]
path = "src/appsignal/__about__.py"

[tool.hatch.build]
sources = ["src"]

[tool.hatch.envs.default]
dependencies = [
"pytest",
"pytest-cov",
]
[tool.hatch.envs.default.scripts]
cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=src --cov=tests {args}"
no-cov = "cov --no-cov {args}"

[[tool.hatch.envs.test.matrix]]
python = ["37", "38", "39", "310", "311"]

[tool.hatch.envs.lint]
detached = true
dependencies = [
"black>=23.1.0",
"mypy>=1.0.0",
"ruff>=0.0.243",
]

[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --check-untyped-defs {args:src tests}"
style = [
"ruff {args:.}",
"black --check --diff {args:.}",
]
fmt = [
"black {args:.}",
"ruff --fix {args:.}",
"style",
]
all = [
"fmt",
"style",
"typing",
]

[tool.coverage.run]
branch = true
parallel = true
omit = [
"src/appsignal/__about__.py",
]

[tool.coverage.report]
exclude_lines = [
"no cov",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]
1 change: 1 addition & 0 deletions src/appsignal/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.1"
Empty file added src/appsignal/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions src/appsignal/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def run():
print("Hello AppSignal!")
4 changes: 4 additions & 0 deletions src/appsignal/something.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def add(a: str, b: str) -> str:
# uncomment the following to trigger a type error
# return a - b
return a + b
Empty file added tests/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions tests/test_something.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from appsignal.something import add


def test_something():
# uncomment the following to trigger a type error:
# assert add(2, 2) == 4
assert add("foo", "bar") == "foobar"

0 comments on commit f7af937

Please sign in to comment.