Skip to content

Commit b580935

Browse files
repo + release plumbing
1 parent 86208aa commit b580935

File tree

17 files changed

+1516
-0
lines changed

17 files changed

+1516
-0
lines changed

.github/workflows/ci.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.11"
19+
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install ruff
24+
25+
- name: Run ruff linter
26+
run: ruff check src/ tests/
27+
28+
- name: Run ruff formatter check
29+
run: ruff format --check src/ tests/
30+
31+
typecheck:
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Set up Python
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: "3.11"
40+
41+
- name: Install dependencies
42+
run: |
43+
python -m pip install --upgrade pip
44+
pip install mypy
45+
46+
- name: Run mypy
47+
run: mypy src/importguard
48+
49+
test:
50+
runs-on: ubuntu-latest
51+
strategy:
52+
matrix:
53+
python-version: ["3.9", "3.10", "3.11", "3.12"]
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- name: Set up Python ${{ matrix.python-version }}
58+
uses: actions/setup-python@v5
59+
with:
60+
python-version: ${{ matrix.python-version }}
61+
62+
- name: Install dependencies
63+
run: |
64+
python -m pip install --upgrade pip
65+
pip install -e ".[dev]"
66+
67+
- name: Run tests
68+
run: pytest tests/ -v --tb=short
69+
70+
- name: Test CLI works
71+
run: |
72+
python -m importguard check json
73+
python -m importguard check os --max-ms 5000
74+

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
tests/__pycache__/
2+
src/__pycache__/
3+
.pytest_cache/
4+
.ruff_cache/
5+
.mypy_cache/
6+
.coverage
7+
.coverage.*
8+
.coverage.*.*
9+
.coverage.*.*.*
10+
.coverage.*.*.*.*
11+
.coverage.*.*.*.*.*
12+
__pycache__/

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Aryan Kumar
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

pyproject.toml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "importguard"
7+
version = "0.1.0"
8+
description = "Measure and enforce import-time behavior in Python projects"
9+
readme = "README.md"
10+
license = "MIT"
11+
authors = [{ name = "Aryan Kumar" }]
12+
requires-python = ">=3.9"
13+
classifiers = [
14+
"Development Status :: 3 - Alpha",
15+
"Environment :: Console",
16+
"Intended Audience :: Developers",
17+
"License :: OSI Approved :: MIT License",
18+
"Operating System :: OS Independent",
19+
"Programming Language :: Python :: 3",
20+
"Programming Language :: Python :: 3.9",
21+
"Programming Language :: Python :: 3.10",
22+
"Programming Language :: Python :: 3.11",
23+
"Programming Language :: Python :: 3.12",
24+
"Topic :: Software Development :: Quality Assurance",
25+
"Topic :: Software Development :: Testing",
26+
"Typing :: Typed",
27+
]
28+
keywords = ["import", "performance", "timing", "cli", "ci", "testing"]
29+
dependencies = []
30+
31+
[project.optional-dependencies]
32+
dev = [
33+
"pytest>=7.0",
34+
"pytest-cov>=4.0",
35+
"ruff>=0.1.0",
36+
"mypy>=1.0",
37+
]
38+
39+
[project.scripts]
40+
importguard = "importguard.cli:main"
41+
42+
[project.urls]
43+
Homepage = "https://github.com/AryanKumar1401/importguard"
44+
Repository = "https://github.com/AryanKumar1401/importguard"
45+
Issues = "https://github.com/AryanKumar1401/importguard/issues"
46+
47+
[tool.hatch.build.targets.wheel]
48+
packages = ["src/importguard"]
49+
50+
[tool.ruff]
51+
target-version = "py39"
52+
line-length = 100
53+
src = ["src", "tests"]
54+
55+
[tool.ruff.lint]
56+
select = [
57+
"E", # pycodestyle errors
58+
"W", # pycodestyle warnings
59+
"F", # pyflakes
60+
"I", # isort
61+
"B", # flake8-bugbear
62+
"C4", # flake8-comprehensions
63+
"UP", # pyupgrade
64+
"RUF", # ruff-specific
65+
]
66+
ignore = [
67+
"E501", # line too long (handled by formatter)
68+
]
69+
70+
[tool.ruff.lint.isort]
71+
known-first-party = ["importguard"]
72+
73+
[tool.mypy]
74+
python_version = "3.9"
75+
strict = true
76+
warn_return_any = true
77+
warn_unused_ignores = true
78+
disallow_untyped_defs = true
79+
files = ["src/importguard"]
80+
81+
[tool.pytest.ini_options]
82+
testpaths = ["tests"]
83+
pythonpath = ["src"]
84+
addopts = "-v --tb=short"
85+
86+
[tool.coverage.run]
87+
source = ["src/importguard"]
88+
branch = true
89+
90+
[tool.coverage.report]
91+
exclude_lines = [
92+
"pragma: no cover",
93+
"if TYPE_CHECKING:",
94+
"raise NotImplementedError",
95+
]
96+

src/importguard/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""importguard - Measure and enforce import-time behavior in Python projects."""
2+
3+
from .core import check_import
4+
from .models import ImportResult, ImportTiming, Violation, ViolationType
5+
6+
__version__ = "0.1.0"
7+
__all__ = [
8+
"ImportResult",
9+
"ImportTiming",
10+
"Violation",
11+
"ViolationType",
12+
"check_import",
13+
]

src/importguard/__main__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""Allow running as python -m importguard."""
2+
3+
import sys
4+
5+
from .cli import main
6+
7+
if __name__ == "__main__":
8+
sys.exit(main())

0 commit comments

Comments
 (0)