Skip to content
This repository was archived by the owner on Jul 13, 2022. It is now read-only.

Commit c9ecb39

Browse files
Initial commit
0 parents  commit c9ecb39

File tree

11 files changed

+323
-0
lines changed

11 files changed

+323
-0
lines changed

.circleci/config.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
version: 2.1
2+
3+
orbs:
4+
aws-cli: circleci/[email protected]
5+
ghpr: narrativescience/[email protected]
6+
7+
jobs:
8+
test:
9+
docker:
10+
- image: cimg/python:3.6
11+
steps:
12+
- aws-cli/install
13+
- ghpr/build-prospective-branch
14+
- run:
15+
name: Install dependencies
16+
command: |
17+
pip install -U pip setuptools
18+
pip install poetry
19+
export CODEARTIFACT_AUTH_TOKEN="$(
20+
aws codeartifact get-authorization-token \
21+
--domain lexio \
22+
--domain-owner "$AWS_ACCOUNT_ID" \
23+
--query authorizationToken \
24+
--output text)"
25+
poetry config repositories.codeartifact "$CODEARTIFACT_URL"
26+
poetry config http-basic.codeartifact aws "$CODEARTIFACT_AUTH_TOKEN"
27+
28+
poetry install
29+
- run:
30+
name: Run commit hooks
31+
command: |
32+
poetry run pre-commit install
33+
poetry run pre-commit run \
34+
--source "origin/${GITHUB_PR_BASE_BRANCH}" \
35+
--origin "origin/${CIRCLE_BRANCH}" \
36+
--show-diff-on-failure
37+
- run: poetry build
38+
- run: poetry run pytest --junit-xml .junit/unit/results.xml
39+
- store_test_results:
40+
path: .junit
41+
- ghpr/post-pr-comment:
42+
comment: Tests failed!
43+
when: on_fail
44+
publish:
45+
docker:
46+
- image: cimg/python:3.6
47+
steps:
48+
- aws-cli/install
49+
- checkout
50+
- run: pip install poetry
51+
- run: poetry install
52+
- run: poetry build
53+
- run:
54+
name: Configure private package repository
55+
command: |
56+
export CODEARTIFACT_AUTH_TOKEN="$(
57+
aws codeartifact get-authorization-token \
58+
--domain lexio \
59+
--domain-owner "$AWS_ACCOUNT_ID" \
60+
--query authorizationToken \
61+
--output text)"
62+
poetry config repositories.codeartifact "$CODEARTIFACT_URL"
63+
poetry config http-basic.codeartifact aws "$CODEARTIFACT_AUTH_TOKEN"
64+
- run: poetry publish -r codeartifact
65+
66+
workflows:
67+
pull_request:
68+
jobs:
69+
- test:
70+
context: lexio-package
71+
filters:
72+
branches:
73+
ignore:
74+
- main
75+
publish:
76+
jobs:
77+
- publish:
78+
context: lexio-package
79+
filters:
80+
tags:
81+
only: /v[0-9]+(\.[0-9]+)*/
82+
branches:
83+
ignore: /.*/

.flake8

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[flake8]
2+
# E203: Conflicts with black's formatting
3+
# E501: Conflicts with black's formatting, which defaults to a max
4+
# line length of 88 but will go over if necessary.
5+
# See https://github.com/ambv/black#line-length for more info
6+
# W605: Conflicts with regular expression formatting
7+
ignore = E203,E501,E731,W503,W605
8+
import-order-style = google
9+
# Packages added in this list should be added to the setup.cfg file as well
10+
application-import-names =
11+
ns_sql_utils
12+
exclude =
13+
*vendor*
14+
.venv
15+
.env
16+
.pants.d
17+
.pantscache
18+
.git
19+
__init__.py
20+
setup.py

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.DS_Store
2+
.venv*
3+
.vscode
4+
**/__pycache__/
5+
**/.cache/
6+
**/.tox
7+
**/*.coverage
8+
**/*.egg-info
9+
**/*.pyc
10+
**/dist

.pre-commit-config.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
default_stages: [commit]
3+
4+
default_language_version:
5+
python: python3
6+
7+
exclude: "examples/.*$"
8+
9+
repos:
10+
- repo: https://github.com/pre-commit/pre-commit-hooks
11+
rev: v2.4.0
12+
hooks:
13+
- id: check-ast
14+
- id: check-builtin-literals
15+
- id: check-byte-order-marker
16+
- id: check-executables-have-shebangs
17+
# Need to define stages explicitly since `default_stages` was not being respected
18+
stages: [commit]
19+
- id: check-merge-conflict
20+
- id: debug-statements
21+
- id: forbid-new-submodules
22+
- id: no-commit-to-branch
23+
- id: trailing-whitespace
24+
args: [--markdown-linebreak-ext=md]
25+
# Need to define stages explicitly since `default_stages` was not being respected
26+
stages: [commit]
27+
28+
- repo: local
29+
hooks:
30+
- id: codespell
31+
name: Spell-check Python files (codespell)
32+
entry: codespell
33+
language: python
34+
types: [file, python]
35+
additional_dependencies: [codespell==2.0.0]
36+
37+
- id: isort
38+
name: Sort Python imports (isort)
39+
entry: isort
40+
language: python
41+
types: [file, python]
42+
additional_dependencies: [isort==4.3.16]
43+
44+
- id: black
45+
name: Format Python (black)
46+
entry: black
47+
language: python
48+
types: [file, python]
49+
additional_dependencies: [black==19.3b0]
50+
51+
- id: pydocstyle
52+
name: Lint Python docstrings (pydocstyle)
53+
entry: pydocstyle
54+
language: python
55+
types: [file, python]
56+
additional_dependencies: [pydocstyle==5.0.2]
57+
58+
- id: flake8
59+
name: Lint Python (flake8)
60+
entry: flake8 --config .flake8
61+
language: python
62+
types: [file, python]
63+
additional_dependencies:
64+
- flake8==3.7.9
65+
- "flake8-import-order<0.19,>=0.18"
66+
- flake8-print>=3.1.4,<4

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright (c) 2021, Narrative Science
2+
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9+
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10+
- Neither the name of the <organization> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11+
12+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
13+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
14+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
15+
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
16+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
17+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
18+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
19+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# ns_sql_utils
2+
3+
Utilities for interacting with sql databases
4+
5+
Features:
6+
7+
- <!-- list of features -->
8+
9+
Table of Contents:
10+
11+
- [Installation](#installation)
12+
- [Guide](#guide)
13+
- [Development](#development)
14+
15+
## Installation
16+
17+
ns_sql_utils requires Python 3.6 or above.
18+
19+
```bash
20+
pip install ns_sql_utils
21+
# or
22+
poetry add ns_sql_utils
23+
```
24+
25+
## Guide
26+
27+
<!-- Subsections explaining how to use the package -->
28+
29+
## Development
30+
31+
To develop ns_sql_utils, install dependencies and enable the pre-commit hook:
32+
33+
```bash
34+
pip install pre-commit poetry
35+
poetry install
36+
pre-commit install
37+
```
38+
39+
To run tests:
40+
41+
```bash
42+
poetry run pytest
43+
```

ns_sql_utils/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""Utilities for interacting with sql databases"""
2+
3+
__version__ = "0.1.0"

ns_sql_utils/example.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"""Contains an example function"""
2+
3+
4+
def foo() -> str:
5+
"""Returns bar"""
6+
return "bar"

pyproject.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[tool.poetry]
2+
name = "ns_sql_utils"
3+
version = "0.1.0"
4+
description = "Utilities for interacting with sql databases"
5+
authors = ["Gregory Berns-Leone <[email protected]>"]
6+
license = "BSD-3-Clause"
7+
readme = "README.md"
8+
homepage = "https://github.com/NarrativeScience/ns_sql_utils"
9+
repository = "https://github.com/NarrativeScience/ns_sql_utils"
10+
11+
[tool.poetry.dependencies]
12+
python = "^3.6.5"
13+
14+
[tool.poetry.dev-dependencies]
15+
pre-commit = "^2.10.1"
16+
pytest = "^6.2.2"
17+
18+
19+
[[tool.poetry.source]]
20+
name = "codeartifact"
21+
url = "https://lexio-231405699240.d.codeartifact.us-east-1.amazonaws.com/pypi/lexio/simple/"
22+
23+
[build-system]
24+
requires = ["poetry-core>=1.0.0"]
25+
build-backend = "poetry.core.masonry.api"

setup.cfg

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[isort]
2+
# These rules should conform to flake8-import-order's google import order style
3+
# and black's styling rules
4+
# If adding a new package to this list, please make sure to update the .flake8 file as
5+
# well
6+
atomic=true
7+
combine_as_imports=true
8+
default_section=THIRDPARTY
9+
force_sort_within_sections=true
10+
include_trailing_comma=true
11+
known_standard_library=typing
12+
known_first_party=
13+
ns_sql_utils
14+
line_length=88
15+
multi_line_output=3
16+
no_lines_before=LOCALFOLDER
17+
order_by_type=false
18+
sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
19+
skip=__init__.py
20+
21+
[pydocstyle]
22+
convention=numpy
23+
add-select=D413,D416,D417
24+
add-ignore=D202,D205,D400,D401,D406,D407
25+
26+
[mypy]
27+
ignore_missing_imports=True
28+
allow_redefinition=True
29+
no_strict_optional=True
30+
follow_imports=silent
31+
disallow_untyped_defs=True
32+
disallow_incomplete_defs=True
33+
warn_unreachable=True

tests/unit/test_example.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""Contains tests for the example module"""
2+
3+
import unittest
4+
5+
from ns_sql_utils.example import foo
6+
7+
8+
class ExampleTests(unittest.TestCase):
9+
"""Tests showing an example"""
10+
11+
def test_example(self):
12+
"""Should be true"""
13+
self.assertEqual(foo(), "bar")

0 commit comments

Comments
 (0)