# =============================================================================
# POETRY BUILD SYSTEM CONFIGURATION
# =============================================================================
# This section tells Poetry how to build your package
[build-system]
requires = ["poetry-core>=2.3.1,<3.0.0"]  # Poetry build backend version
build-backend = "poetry.core.masonry.api"  # Use Poetry's build system

# =============================================================================
# PROJECT METADATA AND CONFIGURATION
# =============================================================================
# All the information about your project that will appear on PyPI
[tool.poetry]
name = "knitout-interpreter"  # Package name on PyPI (use hyphens)
version = "0.1.3"               # Current version (update this for each release)
description = "Support for interpreting knitout files used for controlling automatic V-Bed Knitting machines."
authors = ["Megan Hofmann <m.hofmann@northeastern.edu>"]       # Primary authors
maintainers = ["Megan Hofmann <m.hofmann@northeastern.edu>"]   # Current maintainers
license = "MIT"                 # License type (shows up on PyPI)
readme = "README.md"            # File to use as long description on PyPI
homepage = "https://mhofmann-khoury.github.io/knitout_interpreter/"     # Project website
repository = "https://github.com/mhofmann-Khoury/knitout_interpreter"   # Source code location
documentation = "https://mhofmann-khoury.github.io/knitout_interpreter/"            # Documentation site
keywords = [                    # Keywords for PyPI search
    "knit",
    "machine knit",
    "textile",
    "Northeastern",
    "ACT Lab",
    "fabrication",
    "knitout"
]
classifiers = [                 # PyPI classifiers for categorization
    "Development Status :: 2 - Pre-Alpha",                   # Project maturity
    "Natural Language :: English",                           # Human language
    "Intended Audience :: Developers",                       # Who this is for
    "Intended Audience :: Manufacturing",                    # Industry audience
    "License :: OSI Approved :: MIT License",               # License classifier
    "Operating System :: OS Independent",                   # Platform support
    "Programming Language :: Python :: 3",                 # Python support
    "Programming Language :: Python :: 3.11",              # Specific versions
    "Programming Language :: Python :: 3.12",
    "Programming Language :: Python :: 3.13",
    "Topic :: Scientific/Engineering",                      # Subject area
    "Typing :: Typed",
]

# =============================================================================
# PACKAGE STRUCTURE CONFIGURATION
# =============================================================================
# Tell Poetry where to find your Python packages in your repository
packages = [
    {include = "knitout_interpreter", from = "src"},  # Package is in src/ directory
    # This means Poetry will look for src/knitout_interpreter/ as your main package
]

# =============================================================================
# FILES TO INCLUDE/EXCLUDE IN DISTRIBUTION
# =============================================================================
# Include additional files when building the package for distribution
include = [
    "README.md",                    # Project description
    "LICENSE",                      # License file
    "docs/**/*",                    # All documentation files
    "examples/**/*.k",        # Example input files
    "src/knitout_interpreter/**/*.pg", # Grammar Filese
    "src/knitout_interpreter/py.typed",
]

# Exclude files from the distribution package (keeps package size down)
exclude = [
    "tests/**/*",                   # Don't include test files in distribution
    "docs/_build",                  # Don't include built documentation
    "*.pyc",                        # No compiled Python files
    "*.pgt",
    "*.pgc",
    "__pycache__",                  # No Python cache directories
    ".coverage",                    # No coverage data files
    "htmlcov",                      # No coverage HTML reports
    "requirements.txt",             # No old requirements file
    ".gitignore",                   # No git ignore file
]

# =============================================================================
# RUNTIME DEPENDENCIES
# =============================================================================
# These are packages your project needs to run in production
[tool.poetry.dependencies]
python = ">=3.11,<3.14"                # Minimum Python version (allows 3.11.x, 3.12.x, etc.)
parglare = ">=0.19.0"           # Parser generator library
knit-graphs = ">=0.0.11"         # Knitting graph library
virtual-knitting-machine = ">=0.0.25"  # Virtual knitting machine
importlib_resources = ">=6.5" # For loading parglar grammer file

# =============================================================================
# DEVELOPMENT DEPENDENCIES
# =============================================================================
# These packages are only needed during development and testing
[tool.poetry.group.dev.dependencies]
coverage = "^7.3.0"
black = "^24.10.0"
ruff = "^0.7.4"
isort = "^5.13.2"
mypy = "^1.13.0"
pre-commit = "^3.8.0"
twine = "^5.1.0"

# =============================================================================
# DOCUMENTATION-SPECIFIC DEPENDENCIES
# =============================================================================
# Separate dependency group for building documentation (allows selective installation)
[tool.poetry.group.docs.dependencies]
sphinx = "^7.4.0"
sphinx-rtd-theme = "^3.0.0"
sphinx-autoapi = "^3.4.0"
myst-parser = "^4.0.0"

# =============================================================================
# BLACK CODE FORMATTER CONFIGURATION
# =============================================================================
[tool.black]
line-length = 200
target-version = ["py311"]
extend-exclude = "tests"

# =============================================================================
# RUFF LINTER CONFIGURATION
# =============================================================================
[tool.ruff]
line-length = 200
target-version = "py311"

exclude = [
    ".git",
    ".mypy_cache",
    ".ruff_cache",
    ".venv",
    "__pycache__",
    "build",
    "dist",
    "docs",
    "tests",
]

[tool.ruff.lint]
select = [
    "E",      # pycodestyle errors
    "W",      # pycodestyle warnings
    "F",      # pyflakes
    "I",      # isort
    "N",      # pep8-naming
    "UP",     # pyupgrade
    "B",      # flake8-bugbear
    "C4",     # flake8-comprehensions
    "SIM",    # flake8-simplify
]

ignore = [
    "E501",   # Line too long (handled by Black)
    "E741",   # Ambiguous variable name (l, O, I) - allow single-letter loop variables
    "N801",   # CapWords convention ignored
    "N999",   # Module name conventions ignored
    "N802",
    "N818",
    "N803",
    "UP038",  # Use older isinstance tuple syntax for mypy compatibility
]

[tool.ruff.lint.per-file-ignores]
"tests/**/*.py" = [
    "S101",   # Allow assert statements in tests
]

[tool.ruff.format]
quote-style = "double"
indent-style = "space"

# =============================================================================
# ISORT IMPORT SORTER CONFIGURATION
# =============================================================================
[tool.isort]
profile = "black"
line_length = 200
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
known_first_party = ["knitout_interpreter"]
skip_glob = ["tests/*"]

# =============================================================================
# MYPY STATIC TYPE CHECKER CONFIGURATION
# =============================================================================
[tool.mypy]
python_version = "3.11"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
disallow_untyped_decorators = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_no_return = false
warn_unreachable = true
strict_equality = true
show_error_codes = true
ignore_missing_imports = true
allow_redefinition = true
allow_untyped_globals = true
implicit_reexport = true

# Added to fix duplicate module name error
mypy_path = "src"

disable_error_code = [
    "attr-defined",
    "no-redef",
]

exclude = [
    "tests/",
]

[[tool.mypy.overrides]]
module = "tests.*"
disallow_untyped_defs = false
disallow_incomplete_defs = false
check_untyped_defs = false

# =============================================================================
# COVERAGE.PY CONFIGURATION
# =============================================================================
[tool.coverage.run]
source = ["src"]
omit = [
    "*/tests/*",
    "*/test_*",
    "*/__pycache__/*",
    "*/site-packages/*",
    "*/.venv/*",
]
branch = true

[tool.coverage.report]
exclude_lines = [
    "pragma: no cover",
    "def __repr__",
    "if self.debug:",
    "if settings.DEBUG",
    "raise AssertionError",
    "raise NotImplementedError",
    "if 0:",
    "if __name__ == .__main__.:",
    "class .*\\bProtocol\\):",
    "@(abc\\.)?abstractmethod",
]
show_missing = true
skip_covered = false
skip_empty = true
