Skip to content

Commit

Permalink
New workflow (#18)
Browse files Browse the repository at this point in the history
* refactor: formatted code using black and isort

I also updated packages

* docs: enhanced documentation

used some mkdocs-material features to enhance documentation

* docs: removed ChoiceListParamType from documentation

Since I found an issue with this custom type it is neither imported at the top-level __init__.py file nor documented since I commented that part

* ci: added a safety step in the ci.yml file

Installed package "safety" and added it in the noxfile.py and the ci configuration file

* docs: updated CHANGELOG.md

* docs: updated CONTRIBUTING.md and README.md

README.md: added a "black" code style label
  • Loading branch information
lewoudar committed Aug 13, 2022
1 parent a0032cb commit d84abc7
Show file tree
Hide file tree
Showing 37 changed files with 1,345 additions and 918 deletions.
2 changes: 1 addition & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coverage:
range: "90...100"
round: nearest
precision: 0
precision: 0
12 changes: 9 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ jobs:
- name: Lint
run: nox -s lint
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.10'
- name: Scan packages for vulnerabilities
run: nox -s safety
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.10'
- name: CPython tests
run: nox -s tests-${{ matrix.python }}
if: matrix.python != 'pypy-3.7'
env:
CODECOV_TOKEN: ${{ secrets.codecov_token }}
- name: Pypy tests
run: nox -s tests-pypy3
if: matrix.python == 'pypy-3.7'
if: matrix.python == 'pypy-3.7'
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
if: matrix.python == '3.10'
with:
token: ${{ secrets.codecov_token }}
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
- name: Build and deploy
run: nox -s deploy
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.pypi_token }}
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.pypi_token }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ __pycache__
# packaging / distribution
site
dist
build
build
34 changes: 34 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: local
hooks:
- id: isort
name: isort
entry: poetry run isort click_params tests
language: system
types:
- python
- id: black
name: black
entry: poetry run black click_params tests
language: system
types:
- python
- id: bandit
name: bandit
entry: poetry run bandit -r click_params
language: system
exclude: ^tests/
types:
- python
- id: flake8
name: flake8
entry: poetry run flake8
language: system
types:
- python
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ mkdocs:

python:
install:
- requirements: docs/requirements.txt
- requirements: docs/requirements.txt
16 changes: 13 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.4.0] - 2022-08-13

### Added

- All `ListParamType` subclasses have a new parameter `ignore_empty` that defaults to False.

### Changed

- Renamed `UnionParamType` to `FirstOf` and changed its signature.

## [0.3.0] - 2022-03-14

## Fixed
### Fixed

- An issue when a user is prompted a value for a type inheriting `ListParamType`.

Expand Down Expand Up @@ -35,11 +45,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- Changed .travis.yml and appveyor.yml to take in account nox.

### Removed
- Removed pipenv in favor of poetry.

## [0.1.0] - 2019-07-21

### Added
- First release of the package.
- First release of the package.
81 changes: 42 additions & 39 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ Contributions of all kinds are welcome.

## Bug reports

To submit a bug report, please use the [issue tracker](https://github.com/lewoudar/click_params/issues).
To submit a bug report, please use the [issue tracker](https://github.com/click-contrib/click-params/issues).

Before trying to submit a pull request, make sure that there is not already a similar issue reported.
Before trying to submit an issue, make sure that there is not already a similar one reported.

Your message should contains as much information as possible such as:
- the environment in which you worked (OS name and version, python version, etc..)
Your message should contain as much information as possible such as:

- the environment in which you worked (OS name and version, python version, etc...)
- Guidance on how to reproduce the issue. For example a small piece of code that can be run immediately.
- Tell me **what you mean by failure** i.e what are you expecting to happen.
- Tell me **what you mean by failure** i.e. what are you expecting to happen.

# Fix a bug

Expand All @@ -22,56 +23,58 @@ correct it. Look at [code contribution](#code-contribution) section before submi

## Submit feedback

To submit feedback, again use the [issue tracker](https://github.com/lewoudar/click_params/issues).
To submit feedback, again use the [issue tracker](https://github.com/click-contrib/click-params/issues).

If you want to propose a new feature:
- explain in detail how it would work.
- keep the scope as narrow as possible to make it easier to develop.
- if you want to propose code, just read below the section [code contribution](#code-contribution).
## Code style

## Documentation
Here are some preferences I have when coding:

The documentation is never a simple part to write, if you feel that it can be improved, feel free to propose a pull
request. Just a few things to be aware of:
- The documentation is built with [mkdocs](https://www.mkdocs.org/) using the markdown syntax.
- Try to follow the style of the documentation, for example do not have lines longer than 120 characters, use
single-quotes strings ('hello' instead of "hello") when presenting python code.
- Look at the [code contribution](#code-contribution) section for how to setup the project and commit convention.
- Use single quotes wherever possible. Unfortunately `black` does not allow to enforce this rule.
- When writing a test function, the name should be as obvious as possible about what we want to test. I prefer the
formulation "test_should..<expectation>..when..<condition>". I'm not saying it is the best option all the time, but it
often tends to be more readable.

## Code contribution

Ready to contribute? Here is how to setup the project for local development.
1. Fork the click_params repo on Github.
Ready to contribute? Here is how to set up the project for local development.

1. Fork the click_params repo on GitHub.

2. Clone your fork locally. If you don't know how to proceed,
take a look at this [article](https://help.github.com/en/articles/fork-a-repo).
2. Clone your fork locally. If you don't know how to proceed, take a look at
this [article](https://help.github.com/en/articles/fork-a-repo).

3. Install the dependencies needed by the project. You must first install [poetry](https://python-poetry.org/docs/) on
your computer. After that, you can run:
```bash
```shell
poetry install
```

4. Create a branch for local development
```bash
4. Install the pre-commit hooks
```shell
pre-commit install
```

5. Create a branch for local development
```shell
git checkout -b name-of-bug-or-feature
```

5. When you are done with your work, you need to pass all the tests using [nox](https://nox.thea.codes/en/stable/).
```bash
6. Make sure you respect the [code style](#code-style) when developing.

7. When you are done with your work, you need to pass all the tests using [nox](https://nox.thea.codes/en/stable/).
```shell
nox -s lint tests
```

6. Commit your changes and push your branch to GitHub.
For the commit message, you should use the convention described [here](https://medium.com/@menuka/writing-meaningful-git-commit-messages-a62756b65c81).
It is the convention developed by the angular project. There is just one notable difference I'm adding.
The verb must be conjugated **with the past tense** because I believe we are talking about a done action and not an
action to be performed.
Also for the scope, there is no particular set of scopes, so feel free to add what you thinks suits well your
changes. If you don't have one in mind, don't put anything.

7. Before submitting the pull request, you should verify that you include tests. There is also a code coverage
configured with the project. You can check the pull request status to know if your tests cover all the code you wrote.
If your pull request add functionality, please update the documentation.

8. Submit your pull request through the GitHub website.
8. Commit your changes and push your branch to GitHub. For the commit message, you should use the convention described
[here](https://medium.com/@menuka/writing-meaningful-git-commit-messages-a62756b65c81). It is the convention
developed by the angular project. There is just one notable difference I'm adding. The verb must be conjugated **in
the past tense** because I believe we are talking about a done action and not an action to be performed. Also, for
the scope, there is no particular set of scopes, so feel free to add what you think suits well your changes. If you
don't have one in mind, don't put anything.

9. Before submitting the pull request, you should verify that you include tests. There is also a code coverage
configured with the project. You can check the pull request status to know if your tests cover all the code you
wrote. If your pull request add functionality, please update the documentation.

10. Submit your pull request through the GitHub website.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![Coverage Status](https://codecov.io/gh/click-contrib/click_params/branch/master/graphs/badge.svg?branch=master)](https://codecov.io/gh/click-contrib/click_params)
[![Documentation Status](https://readthedocs.org/projects/click_params/badge/?version=latest)](https://click-params.readthedocs.io/en/latest/?badge=latest)
[![License Apache 2](https://img.shields.io/hexpm/l/plug.svg)](http://www.apache.org/licenses/LICENSE-2.0)
[![Code Style](https://img.shields.io/badge/code%20style-black-black)](https://github.com/click-contrib/click_params)

A bunch of useful click parameter types.

Expand Down Expand Up @@ -51,4 +52,3 @@ You can change the default separator "," by passing it when initializing the par
## Documentation

Documentation is available at https://click-params.readthedocs.io/en/latest/.

123 changes: 95 additions & 28 deletions click_params/__init__.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,113 @@
__version__ = '0.2.0'

from .base import BaseParamType, ValidatorParamType, RangeParamType, ListParamType
from .base import BaseParamType, ListParamType, RangeParamType, ValidatorParamType
from .domain import (
DOMAIN, PUBLIC_URL, URL, EMAIL, SLUG, EmailParamType, DomainListParamType, PublicUrlListParamType,
UrlListParamType, EmailListParamType, SlugListParamType
DOMAIN,
EMAIL,
PUBLIC_URL,
SLUG,
URL,
DomainListParamType,
EmailListParamType,
EmailParamType,
PublicUrlListParamType,
SlugListParamType,
UrlListParamType,
)
from .miscellaneous import (
JSON, MAC_ADDRESS, StringListParamType, ChoiceListParamType, MacAddressListParamType, UUIDListParamType,
DateTimeListParamType, FirstOf
from .miscellaneous import ( # ChoiceListParamType,
JSON,
MAC_ADDRESS,
DateTimeListParamType,
FirstOf,
MacAddressListParamType,
StringListParamType,
UUIDListParamType,
)
from .network import (
IP_ADDRESS, IPV4_ADDRESS, IPV6_ADDRESS, IP_NETWORK, IPV4_NETWORK, IPV6_NETWORK, Ipv4AddressRange, Ipv6AddressRange,
IpAddressListParamType, Ipv4AddressListParamType, Ipv6AddressListParamType, IpNetworkListParamType,
Ipv4NetworkListParamType, Ipv6NetworkListParamType
IP_ADDRESS,
IP_NETWORK,
IPV4_ADDRESS,
IPV4_NETWORK,
IPV6_ADDRESS,
IPV6_NETWORK,
IpAddressListParamType,
IpNetworkListParamType,
Ipv4AddressListParamType,
Ipv4AddressRange,
Ipv4NetworkListParamType,
Ipv6AddressListParamType,
Ipv6AddressRange,
Ipv6NetworkListParamType,
)
from .numeric import (
COMPLEX, FRACTION, DECIMAL, DecimalRange, FractionRange, IntListParamType, FloatListParamType,
FractionListParamType, DecimalListParamType, ComplexListParamType
COMPLEX,
DECIMAL,
FRACTION,
ComplexListParamType,
DecimalListParamType,
DecimalRange,
FloatListParamType,
FractionListParamType,
FractionRange,
IntListParamType,
)
from .test_utils import assert_list_in_output, assert_equals_output, assert_in_output
from .test_utils import assert_equals_output, assert_in_output, assert_list_in_output

__all__ = [
# base
'BaseParamType', 'ValidatorParamType', 'RangeParamType', 'ListParamType',

'BaseParamType',
'ValidatorParamType',
'RangeParamType',
'ListParamType',
# domain
'DOMAIN', 'PUBLIC_URL', 'URL', 'EmailParamType', 'EMAIL', 'SLUG', 'DomainListParamType', 'PublicUrlListParamType',
'UrlListParamType', 'EmailListParamType', 'SlugListParamType',

'DOMAIN',
'PUBLIC_URL',
'URL',
'EmailParamType',
'EMAIL',
'SLUG',
'DomainListParamType',
'PublicUrlListParamType',
'UrlListParamType',
'EmailListParamType',
'SlugListParamType',
# miscellaneous
'JSON', 'MAC_ADDRESS', 'ChoiceListParamType', 'StringListParamType', 'MacAddressListParamType', 'UUIDListParamType',
'DateTimeListParamType', 'FirstOf',

'JSON',
'MAC_ADDRESS',
# 'ChoiceListParamType',
'StringListParamType',
'MacAddressListParamType',
'UUIDListParamType',
'DateTimeListParamType',
'FirstOf',
# network
'IP_ADDRESS', 'IPV6_ADDRESS', 'IPV4_ADDRESS', 'IP_NETWORK', 'IPV4_NETWORK', 'IPV6_NETWORK', 'Ipv4AddressRange',
'Ipv6AddressRange', 'IpAddressListParamType', 'Ipv4AddressListParamType', 'Ipv6AddressListParamType',
'Ipv4NetworkListParamType', 'IpNetworkListParamType', 'Ipv6NetworkListParamType',

'IP_ADDRESS',
'IPV6_ADDRESS',
'IPV4_ADDRESS',
'IP_NETWORK',
'IPV4_NETWORK',
'IPV6_NETWORK',
'Ipv4AddressRange',
'Ipv6AddressRange',
'IpAddressListParamType',
'Ipv4AddressListParamType',
'Ipv6AddressListParamType',
'Ipv4NetworkListParamType',
'IpNetworkListParamType',
'Ipv6NetworkListParamType',
# numeric
'FRACTION', 'FractionRange', 'DECIMAL', 'DecimalRange', 'COMPLEX', 'IntListParamType', 'FloatListParamType',
'FractionListParamType', 'DecimalListParamType', 'ComplexListParamType',

'FRACTION',
'FractionRange',
'DECIMAL',
'DecimalRange',
'COMPLEX',
'IntListParamType',
'FloatListParamType',
'FractionListParamType',
'DecimalListParamType',
'ComplexListParamType',
# test_utils
'assert_equals_output', 'assert_in_output', 'assert_list_in_output'
'assert_equals_output',
'assert_in_output',
'assert_list_in_output',
]

0 comments on commit d84abc7

Please sign in to comment.