Skip to content

Library and CLI tool for parsing, validating, modifying, and updating pyproject.toml files

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

patrickarmengol/pptoml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pptoml

PyPI - Version PyPI - Python Version

Library and CLI tool for parsing, validating, modifying, and updating pyproject.toml files.


Table of Contents

Installation

as a module

<virtual environment shenanigans>
pip install pptoml

as a cli app

pipx install pptoml

Usage

as a module

from pathlib import Path
from pptoml.inout import load_config
from pptoml.fetch import fetch_info

config = load_config(Path('path/to/pyproject.toml'))
info = fetch_info(config)

as a cli app

$ pptoml --help

 Usage: pptoml [OPTIONS] COMMAND [ARGS]...

 cli for pptoml

╭─ Options ───────────────────────────────────────────╮
│ --install-completion          Install completion    │
│                               for the current       │
│                               shell.                │
│ --show-completion             Show completion for   │
│                               the current shell, to │
│                               copy it or customize  │
│                               the installation.     │
│ --help                        Show this message and │
│                               exit.                 │
╰─────────────────────────────────────────────────────╯
╭─ Commands ──────────────────────────────────────────╮
│ dump      print pyproject config in specified       │
│           format                                    │
│ get       print the value of the specified field    │
│ info      fetch generally useful info about the     │
│           project from the pyproject config         │
│ new       generate a pyproject.toml file            │
│ validate  validate pyproject against PEP            │
│           specifications                            │
╰─────────────────────────────────────────────────────╯

example info fetch

$ pptoml info
name                          pptoml
description                   Library and CLI tool for parsing, validating, modifying, and updating `pyproject.toml` files. 
authors                       Patrick Armengol
python_version                >=3.7
dependencies                  typer, tomli, validate-pyproject, questionary
license                       Apache-2.0 OR MIT
multi_licensed                True
scripts                       pptoml
docs_url                      https://github.com/patrickarmengol/pptoml#readme
issues_url                    https://github.com/patrickarmengol/pptoml/issues
source_url                    https://github.com/patrickarmengol/pptoml
build_backend                 hatchling
type_checking                 pyright
formatting                    autopep8
linting                       ruff
testing                       coverage
other_tools                   hatch

example new pyproject.toml generation

$ pptoml new
? backend:  hatchling
? project name:  asdf
? project description:  does something i think
? licenses:  [MIT]
? author name:  Pat Cat
? author email:  pat@cat.cat
? github username (for urls):  patthecat
? tools:  done (3 selections)
? max line length (for tools):  120
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "asdf"
version = "0.0.1"
description = 'does something i think'
readme = "README.md"
requires-python = ">=3.7"
license = "MIT"
license-files = { globs = ["LICENSE*"] }
keywords = []
authors = [
  { name = "Pat Cat", email = "pat@cat.cat" },
]
classifiers = [
  "Development Status :: 4 - Beta",
  "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",
]
dependencies = []

[project.scripts]

[project.urls]
Documentation = "https://github.com/patthecat/asdf#readme"
Issues = "https://github.com/patthecat/asdf/issues"
Source = "https://github.com/patthecat/asdf"

[tool.pyright]
include = ["src/pptoml", "tests"]
exclude = [
    "**/__pycache__",
]
typeCheckingMode = "strict"

[tool.ruff]
target-version = "py37"
line-length = 120
select = ["A", "B", "C", "E", "F", "FBT", "I", "N", "Q", "RUF", "S", "T", "UP", "W", "YTT"]
ignore = [
  # Allow non-abstract empty methods in abstract base classes
  "B027",
  # Ignore McCabe complexity
  "C901",
  # Allow boolean positional values in function calls, like `dict.get(... True)`
  "FBT003",
  # Ignore checks for possible passwords
  "S105", "S106", "S107",
]
unfixable = [
  # Don't touch unused imports
  "F401",
]

[tool.ruff.isort]
known-first-party = ["pptoml"]

[tool.ruff.flake8-tidy-imports]
ban-relative-imports = "all"

[tool.ruff.per-file-ignores]
# Tests can use relative imports and assertions
"tests/**/*" = ["I252", "S101"]

[tool.autopep8]
max_line_length = 120

Roadmap

0.1.0

  • fetch general info for the project
  • dump config in various formats

0.2.0

using existing validate-pyproject library to validate

postponed support for PEP 639, tracked in abravalheri/validate-pyproject#70

  • validate with schema

0.3.0

  • generate new pyproject.toml with prompts

0.4.0

the following depend on tomlkit, which is a bit broken for type hinting atm

  • update version
  • add, remove dependencies

0.5.0

  • check for dep updates

License

pptoml is distributed under the terms of any of the following licenses:

About

Library and CLI tool for parsing, validating, modifying, and updating pyproject.toml files

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages