feat: Initial commit with a skeleton project
commit
e01fa1708b
@ -0,0 +1,21 @@
|
|||||||
|
name: 'Setup Python + Poetry environment'
|
||||||
|
description: 'Setup Python + Poetry environment'
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
python-version:
|
||||||
|
required: false
|
||||||
|
description: 'Python version'
|
||||||
|
default: '3.9'
|
||||||
|
outputs: {}
|
||||||
|
runs:
|
||||||
|
using: 'composite'
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{inputs.python-version}}
|
||||||
|
- name: Install poetry
|
||||||
|
run: python -m pip install poetry
|
||||||
|
shell: bash
|
||||||
|
- name: Create virtual environment
|
||||||
|
run: poetry install
|
||||||
|
shell: bash
|
@ -0,0 +1,8 @@
|
|||||||
|
## Description
|
||||||
|
|
||||||
|
A short description about the changes in this pull request. If the pull request is related to some issue, mention it
|
||||||
|
here.
|
||||||
|
|
||||||
|
## Checklist
|
||||||
|
|
||||||
|
- [ ] Documentation has been updated OR the change is too minor to be documented
|
@ -0,0 +1,80 @@
|
|||||||
|
name: Build and Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "**"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
actionlint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Download actionlint
|
||||||
|
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
|
||||||
|
shell: bash
|
||||||
|
- name: Check workflow files
|
||||||
|
run: ./actionlint -color
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
lint-cruft:
|
||||||
|
name: Check if automatic project update was successful
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Fail if .rej files exist as structure update was not successful
|
||||||
|
run: test -z "$(find . -iname '*.rej')"
|
||||||
|
|
||||||
|
pre-commit:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: ./.github/actions/python-poetry-env
|
||||||
|
- run: make pre-commit
|
||||||
|
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
python-version: [ "3.7", "3.8", "3.9" ]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: ./.github/actions/python-poetry-env
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- run: make tests
|
||||||
|
|
||||||
|
release:
|
||||||
|
if: "startsWith(github.event.head_commit.message, 'bump:')"
|
||||||
|
needs: test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: ./.github/actions/python-poetry-env
|
||||||
|
- name: Get latest version
|
||||||
|
id: latest_version
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
version=$(poetry version --short)
|
||||||
|
echo ::set-output name="version::$version"
|
||||||
|
- name: Changelog
|
||||||
|
id: changelog
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
VERSION=${{ steps.latest_version.outputs.version }}
|
||||||
|
body=$(sed -n '/^## '$VERSION'/,/^##.*)$/p' CHANGELOG.md | sed '$d')
|
||||||
|
body="${body//'%'/'%25'}"
|
||||||
|
body="${body//$'\n'/'%0A'}"
|
||||||
|
body="${body//$'\r'/'%0D'}"
|
||||||
|
echo ::set-output name="body::$body"
|
||||||
|
- name: Create release
|
||||||
|
uses: softprops/action-gh-release@v0.1.14
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.PERSONAL_GH_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ steps.latest_version.outputs.version }}
|
||||||
|
name: Release ${{ steps.latest_version.outputs.version }}
|
||||||
|
body: ${{ steps.changelog.outputs.body }}
|
||||||
|
generate_release_notes: true
|
@ -0,0 +1,57 @@
|
|||||||
|
name: Autoupdate dependencies
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 0 1 * *"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
auto-update-dependencies:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: ./.github/actions/python-poetry-env
|
||||||
|
|
||||||
|
- name: Install tabulate
|
||||||
|
run: python -m pip install tabulate
|
||||||
|
|
||||||
|
- name: Gather outdated dependencies
|
||||||
|
id: check_for_outdated_dependencies
|
||||||
|
run: |
|
||||||
|
body=$(poetry show -o -n)
|
||||||
|
echo ::set-output name="body::$body"
|
||||||
|
|
||||||
|
- name: Format PR message
|
||||||
|
if: ${{ steps.check_for_outdated_dependencies.outputs.body != 0 }}
|
||||||
|
id: get_outdated_dependencies
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
body=$(poetry show -o -n | sed 's/(!)//' | awk 'BEGIN {print "Package","Used","Update"}; {print $1,$2,$3}' | tabulate --header --format github -)
|
||||||
|
body=$(cat <<EOF
|
||||||
|
The following packages are outdated
|
||||||
|
|
||||||
|
$body
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
body="${body//'%'/'%25'}"
|
||||||
|
body="${body//$'\n'/'%0A'}"
|
||||||
|
body="${body//$'\r'/'%0D'}"
|
||||||
|
echo ::set-output name="body::$body"
|
||||||
|
|
||||||
|
- name: Update outdated packages
|
||||||
|
if: ${{ steps.check_for_outdated_dependencies.outputs.body != 0 }}
|
||||||
|
run: make deps
|
||||||
|
|
||||||
|
# behaviour if PR already exists: https://github.com/marketplace/actions/create-pull-request#action-behaviour
|
||||||
|
- name: Create Pull Request
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
if: ${{ steps.check_for_outdated_dependencies.outputs.body != 0 }}
|
||||||
|
uses: peter-evans/create-pull-request@v3
|
||||||
|
with:
|
||||||
|
token: ${{ env.GITHUB_TOKEN }}
|
||||||
|
commit-message: >-
|
||||||
|
chore: update dependencies
|
||||||
|
title: "[Actions] Auto-Update dependencies"
|
||||||
|
body: ${{ steps.get_outdated_dependencies.outputs.body }}
|
||||||
|
branch: chore/update-dependencies
|
||||||
|
delete-branch: true
|
@ -0,0 +1,18 @@
|
|||||||
|
name: Publish
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [ published ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: ./.github/actions/python-poetry-env
|
||||||
|
- name: Publish to pypi
|
||||||
|
run: |
|
||||||
|
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
|
||||||
|
poetry publish --build --no-interaction
|
||||||
|
- name: Deploy docs
|
||||||
|
run: poetry run mkdocs gh-deploy --force
|
@ -0,0 +1,85 @@
|
|||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
|
||||||
|
# IDEs
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
fireprofile
|
||||||
|
geckodriver.log
|
||||||
|
backroom/
|
||||||
|
.temp/
|
@ -0,0 +1,64 @@
|
|||||||
|
fail_fast: true
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.1.0
|
||||||
|
hooks:
|
||||||
|
- id: check-ast
|
||||||
|
- id: check-added-large-files
|
||||||
|
- id: check-merge-conflict
|
||||||
|
- id: check-case-conflict
|
||||||
|
- id: check-docstring-first
|
||||||
|
- id: check-json
|
||||||
|
- id: check-yaml
|
||||||
|
- id: debug-statements
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- id: mixed-line-ending
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: autoflake
|
||||||
|
name: autoflake
|
||||||
|
entry: poetry run autoflake -r -i --remove-all-unused-imports --remove-unused-variables
|
||||||
|
language: system
|
||||||
|
types: [ python ]
|
||||||
|
- id: isort
|
||||||
|
name: isort
|
||||||
|
entry: poetry run isort
|
||||||
|
language: system
|
||||||
|
types: [python]
|
||||||
|
- id: black
|
||||||
|
name: black
|
||||||
|
entry: poetry run black
|
||||||
|
language: system
|
||||||
|
types: [python]
|
||||||
|
- id: pyupgrade
|
||||||
|
name: pyupgrade
|
||||||
|
entry: pyupgrade --py37-plus
|
||||||
|
language: system
|
||||||
|
types: [python]
|
||||||
|
- id: mypy
|
||||||
|
name: mypy
|
||||||
|
entry: poetry run mypy .
|
||||||
|
require_serial: true
|
||||||
|
language: system
|
||||||
|
types: [python]
|
||||||
|
pass_filenames: false
|
||||||
|
- id: flake8
|
||||||
|
name: flake8
|
||||||
|
entry: poetry run flake8
|
||||||
|
language: system
|
||||||
|
types: [python]
|
||||||
|
- repo: https://github.com/commitizen-tools/commitizen
|
||||||
|
rev: v2.21.2
|
||||||
|
hooks:
|
||||||
|
- id: commitizen
|
||||||
|
stages: [commit-msg]
|
||||||
|
- repo: https://github.com/sondrelg/pep585-upgrade
|
||||||
|
rev: v1
|
||||||
|
hooks:
|
||||||
|
- id: upgrade-type-hints
|
||||||
|
args: [ '--futures=true' ]
|
||||||
|
- repo: https://github.com/syntaqx/git-hooks
|
||||||
|
rev: v0.0.17
|
||||||
|
hooks:
|
||||||
|
- id: shellcheck
|
@ -0,0 +1,20 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2023 namuan <github@deskriders.dev>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@ -0,0 +1,47 @@
|
|||||||
|
export PROJECTNAME=$(shell basename "$(PWD)")
|
||||||
|
|
||||||
|
.SILENT: ; # no need for @
|
||||||
|
|
||||||
|
new-project: ## Instruction to setup a new project. Run ./init-new-project.sh NEW_PROJECT_NAME
|
||||||
|
echo "Run ./init-new-project.sh NEW_PROJECT_NAME"
|
||||||
|
|
||||||
|
setup: ## Setup Virtual Env
|
||||||
|
poetry install
|
||||||
|
|
||||||
|
deps: ## Install/Update dependencies
|
||||||
|
poetry lock
|
||||||
|
poetry run pre-commit autoupdate
|
||||||
|
|
||||||
|
clean: ## Clean package
|
||||||
|
find . -type d -name '__pycache__' | xargs rm -rf
|
||||||
|
find . -type d -name '.temp' | xargs rm -rf
|
||||||
|
find . -type f -name '.coverage' | xargs rm -rf
|
||||||
|
rm -rf build dist
|
||||||
|
|
||||||
|
comby: ## Generic rules (required comby https://comby.dev/docs/)
|
||||||
|
comby 'print(:[1])' 'logging.info(:[1])' -directory 'src' -extensions 'py' -in-place
|
||||||
|
|
||||||
|
pre-commit: ## Manually run all precommit hooks
|
||||||
|
poetry run pre-commit run --all-files
|
||||||
|
|
||||||
|
pre-commit-tool: ## Manually run a single pre-commit hook
|
||||||
|
poetry run pre-commit run $(TOOL) --all-files
|
||||||
|
|
||||||
|
build: pre-commit ## Build package
|
||||||
|
poetry build
|
||||||
|
|
||||||
|
bump: build ## Bump version and update changelog
|
||||||
|
poetry run cz bump --changelog
|
||||||
|
|
||||||
|
bpython: ## Runs bpython
|
||||||
|
bpython
|
||||||
|
|
||||||
|
.PHONY: help
|
||||||
|
.DEFAULT_GOAL := help
|
||||||
|
|
||||||
|
help: Makefile
|
||||||
|
echo
|
||||||
|
echo " Choose a command run in "$(PROJECTNAME)":"
|
||||||
|
echo
|
||||||
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||||
|
echo
|
@ -0,0 +1,58 @@
|
|||||||
|
# Doc Search
|
||||||
|
|
||||||
|
[![PyPI](https://img.shields.io/pypi/v/dr-doc-search?style=flat-square)](https://pypi.python.org/pypi/dr-doc-search/)
|
||||||
|
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/dr-doc-search?style=flat-square)](https://pypi.python.org/pypi/dr-doc-search/)
|
||||||
|
[![PyPI - License](https://img.shields.io/pypi/l/dr-doc-search?style=flat-square)](https://pypi.python.org/pypi/dr-doc-search/)
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Documentation**: [https://namuan.github.io/dr-doc-search](https://namuan.github.io/dr-doc-search)
|
||||||
|
|
||||||
|
**Source Code**: [https://github.com/namuan/dr-doc-search](https://github.com/namuan/dr-doc-search)
|
||||||
|
|
||||||
|
**PyPI**: [https://pypi.org/project/dr-doc-search/](https://pypi.org/project/dr-doc-search/)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Search through a document using a chat interface.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pip install dr-doc-search
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example Usage
|
||||||
|
|
||||||
|
```shell
|
||||||
|
dr-doc-search --help
|
||||||
|
```
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
* Clone this repository
|
||||||
|
* Requirements:
|
||||||
|
* Python 3.7+
|
||||||
|
* [Poetry](https://python-poetry.org/)
|
||||||
|
* [Comby](https://comby.dev/docs/)
|
||||||
|
|
||||||
|
* Create a virtual environment and install the dependencies
|
||||||
|
```sh
|
||||||
|
poetry install
|
||||||
|
```
|
||||||
|
|
||||||
|
* Activate the virtual environment
|
||||||
|
```sh
|
||||||
|
poetry shell
|
||||||
|
```
|
||||||
|
|
||||||
|
### Validating build
|
||||||
|
```sh
|
||||||
|
make build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Release process
|
||||||
|
A release is automatically published when a new version is bumped using `make bump`.
|
||||||
|
See `.github/workflows/build.yml` for more details.
|
||||||
|
Once the release is published, `.github/workflows/publish.yml` will automatically publish it to PyPI.
|
@ -0,0 +1 @@
|
|||||||
|
--8<-- "CHANGELOG.md"
|
@ -0,0 +1 @@
|
|||||||
|
--8<-- "README.md"
|
@ -0,0 +1,25 @@
|
|||||||
|
site_name: Twitter tools - Collection of twitter utilities.
|
||||||
|
repo_url: https://github.com/namuan/twitter-utils
|
||||||
|
|
||||||
|
theme:
|
||||||
|
name: material
|
||||||
|
palette:
|
||||||
|
- scheme: default
|
||||||
|
toggle:
|
||||||
|
icon: material/toggle-switch-off-outline
|
||||||
|
name: Switch to dark mode
|
||||||
|
- scheme: slate
|
||||||
|
toggle:
|
||||||
|
icon: material/toggle-switch
|
||||||
|
name: Switch to light mode
|
||||||
|
|
||||||
|
nav:
|
||||||
|
- Introduction: 'index.md'
|
||||||
|
- changelog.md
|
||||||
|
|
||||||
|
markdown_extensions:
|
||||||
|
- pymdownx.snippets:
|
||||||
|
check_paths: true
|
||||||
|
|
||||||
|
plugins:
|
||||||
|
- search:
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,2 @@
|
|||||||
|
[virtualenvs]
|
||||||
|
in-project = true
|
@ -0,0 +1,92 @@
|
|||||||
|
[tool.poetry]
|
||||||
|
name = "dr-doc-search"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "Search through a document using a chat interface"
|
||||||
|
authors = [
|
||||||
|
"namuan <github@deskriders.dev>",
|
||||||
|
]
|
||||||
|
license = "MIT"
|
||||||
|
readme = "README.md"
|
||||||
|
|
||||||
|
documentation = "https://namuan.github.io/dr-doc-search"
|
||||||
|
homepage = "https://namuan.github.io/dr-doc-search"
|
||||||
|
repository = "https://github.com/namuan/dr-doc-search"
|
||||||
|
|
||||||
|
classifiers = [
|
||||||
|
"Development Status :: 4 - Beta",
|
||||||
|
"Intended Audience :: Developers",
|
||||||
|
"Operating System :: OS Independent",
|
||||||
|
"Programming Language :: Python",
|
||||||
|
"Programming Language :: Python :: 3",
|
||||||
|
"Programming Language :: Python :: 3.8",
|
||||||
|
"Programming Language :: Python :: 3.9",
|
||||||
|
"Programming Language :: Python :: 3.10",
|
||||||
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||||
|
"Typing :: Typed",
|
||||||
|
]
|
||||||
|
|
||||||
|
packages = [
|
||||||
|
{ include = "doc_search", from = "src" }
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.poetry.dependencies]
|
||||||
|
python = ">=3.9.0, <4.0"
|
||||||
|
py-executable-checklist = "1.3.1"
|
||||||
|
rich = "^13.0.0"
|
||||||
|
|
||||||
|
[tool.poetry.dev-dependencies]
|
||||||
|
autoflake = "*"
|
||||||
|
black = "*"
|
||||||
|
flake8 = "*"
|
||||||
|
flake8-bugbear = "*"
|
||||||
|
flake8-builtins = "*"
|
||||||
|
flake8-comprehensions = "*"
|
||||||
|
flake8-debugger = "*"
|
||||||
|
flake8-logging-format = "*"
|
||||||
|
isort = "*"
|
||||||
|
mkdocstrings = "*"
|
||||||
|
mkdocs-material = "9.0.1"
|
||||||
|
mypy = "*"
|
||||||
|
pep8-naming = "*"
|
||||||
|
pre-commit = "*"
|
||||||
|
pymdown-extensions = "*"
|
||||||
|
python-kacl = "*"
|
||||||
|
pyupgrade = "*"
|
||||||
|
tryceratops = "*"
|
||||||
|
commitizen = "^2.20.3"
|
||||||
|
|
||||||
|
[tool.commitizen]
|
||||||
|
name = "cz_conventional_commits"
|
||||||
|
version = "0.5.0"
|
||||||
|
tag_format = "$version"
|
||||||
|
version_files = [
|
||||||
|
"pyproject.toml:version",
|
||||||
|
]
|
||||||
|
update_changelog_on_bump = true
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["poetry-core>=1.0.0"]
|
||||||
|
build-backend = "poetry.core.masonry.api"
|
||||||
|
|
||||||
|
[tool.isort]
|
||||||
|
profile = "black"
|
||||||
|
src_paths = ["src", "tests"]
|
||||||
|
|
||||||
|
[tool.black]
|
||||||
|
line-length = 120
|
||||||
|
target-version = ["py37", "py38", "py39"]
|
||||||
|
include = '\.pyi?$'
|
||||||
|
|
||||||
|
[tool.mypy]
|
||||||
|
disallow_any_unimported = true
|
||||||
|
disallow_untyped_defs = true
|
||||||
|
no_implicit_optional = true
|
||||||
|
strict_equality = true
|
||||||
|
warn_unused_ignores = true
|
||||||
|
warn_redundant_casts = true
|
||||||
|
warn_return_any = true
|
||||||
|
check_untyped_defs = true
|
||||||
|
show_error_codes = true
|
||||||
|
|
||||||
|
[tool.poetry.scripts]
|
||||||
|
dr-doc-search = 'doc_search.app:main'
|
@ -0,0 +1,37 @@
|
|||||||
|
[flake8]
|
||||||
|
ignore =
|
||||||
|
# Line break occurred before a binary operator (W503)
|
||||||
|
# https://github.com/psf/black/issues/52
|
||||||
|
W503,
|
||||||
|
# Line too long (E501)
|
||||||
|
# 1. black does not format comments
|
||||||
|
# https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#comments
|
||||||
|
# 2. long links in doc strings are an issue
|
||||||
|
E501
|
||||||
|
# flake8-builtins
|
||||||
|
# the likelihood of running into an issue when shadowing a buildin
|
||||||
|
# with a class attribute is very low
|
||||||
|
A003,
|
||||||
|
# flake8-bugbear
|
||||||
|
# fastapi recommends to use `Depend()` as an argument default.
|
||||||
|
# Unfortuantely, exceptions are hardcoded in bugbear.
|
||||||
|
# https://github.com/PyCQA/flake8-bugbear/issues/62
|
||||||
|
B008,
|
||||||
|
|
||||||
|
# pep8-naming
|
||||||
|
classmethod-decorators =
|
||||||
|
classmethod, # built-in
|
||||||
|
validator, # pydantic
|
||||||
|
root_validator, # pydantic
|
||||||
|
|
||||||
|
enable-extensions=
|
||||||
|
G, # flake8-logging-format
|
||||||
|
|
||||||
|
per-file-ignores =
|
||||||
|
# star imports in `__init__.py` files are ok
|
||||||
|
*/__init__.py: F401
|
||||||
|
|
||||||
|
# Enables maccabe complexity checks
|
||||||
|
max-complexity = 10
|
||||||
|
|
||||||
|
exclude = .git,__pycache__,old,build,dist,.venv,.eggs,.tox
|
@ -0,0 +1,22 @@
|
|||||||
|
import logging
|
||||||
|
import random
|
||||||
|
import string
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
def setup_logging(verbosity): # pragma: no cover
|
||||||
|
logging_level = logging.WARNING
|
||||||
|
if verbosity == 1:
|
||||||
|
logging_level = logging.INFO
|
||||||
|
elif verbosity >= 2:
|
||||||
|
logging_level = logging.DEBUG
|
||||||
|
|
||||||
|
logging.basicConfig(
|
||||||
|
handlers=[
|
||||||
|
logging.StreamHandler(),
|
||||||
|
],
|
||||||
|
format="%(asctime)s - %(filename)s:%(lineno)d - %(message)s",
|
||||||
|
datefmt="%Y-%m-%d %H:%M:%S",
|
||||||
|
level=logging_level,
|
||||||
|
)
|
||||||
|
logging.captureWarnings(capture=True)
|
@ -0,0 +1,34 @@
|
|||||||
|
"""
|
||||||
|
Indexes a PDF file and generate OpenAI Embeddings
|
||||||
|
"""
|
||||||
|
import logging
|
||||||
|
from argparse import ArgumentParser, Namespace, RawDescriptionHelpFormatter
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from doc_search import setup_logging
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args() -> Namespace:
|
||||||
|
parser = ArgumentParser(description=__doc__, formatter_class=RawDescriptionHelpFormatter)
|
||||||
|
parser.add_argument(
|
||||||
|
"-i", "--input", required=True, type=Path, help="Path to input file"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-v",
|
||||||
|
"--verbose",
|
||||||
|
action="count",
|
||||||
|
default=0,
|
||||||
|
dest="verbose",
|
||||||
|
help="Increase verbosity of logging output",
|
||||||
|
)
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None: # pragma: no cover
|
||||||
|
args = parse_args()
|
||||||
|
setup_logging(args.verbose)
|
||||||
|
logging.info("Do something")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__": # pragma: no cover
|
||||||
|
main()
|
Loading…
Reference in New Issue