Skip to content

Commit

Permalink
Made various libraries upgrade + ruff linting (#24)
Browse files Browse the repository at this point in the history
* chore: applied ruff to the project

installed ruff
applied ruff lint and format
removed useless packages: black, isort, flake8
updated noxfile.py to use ruff for linting
removed setup.cfg

* ci: updated Github CI files and .pre-commit-config.yaml

Drop support for Python 3.7

* build(poetry): upgraded minimum python version

* fix: fixed pydantic issue

* fix: fixed ruff rule

* test: fix zsh completion test

* chore: upgraded pydantic to v2

* docs: updated CHANGELOG.md, README.md and mkdocs documentation

* fix: fixed Annotated import

For Python 3.8, we must import Annotated from typing_extensions

* test: skipped one test in test_tail.py module

This test does not work on Pypy for now.

* docs: updated code style logo in README.md

replaced black with ruff
  • Loading branch information
lewoudar authored Nov 24, 2023
1 parent aefecd6 commit bf0bb56
Show file tree
Hide file tree
Showing 37 changed files with 1,307 additions and 1,132 deletions.
4 changes: 0 additions & 4 deletions .coverage.yml

This file was deleted.

20 changes: 10 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,37 @@ jobs:
max-parallel: 6
matrix:
os: [ 'ubuntu-latest', 'macos-latest' ,'windows-latest' ]
python: [ pypy-3.7, 3.7, 3.8, 3.9, '3.10', '3.11' ]
python: [ 'pypy-3.8', '3.8', '3.9', '3.10', '3.11', '3.12' ]
exclude:
# unable to install cryptography on this job
- os: macos-latest
python: pypy-3.7
python: pypy-3.8
# weird error when installing packages with poetry
- os: windows-latest
python: pypy-3.7
python: pypy-3.8

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install python dependencies
run: python -m pip install -U pip nox
- name: Lint
run: nox -s lint
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.11'
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12'
- name: Scan packages for vulnerabilities
run: nox -s safety
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.11'
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12'
- name: CPython tests
run: nox -s tests-${{ matrix.python }}
if: matrix.python != 'pypy-3.7'
if: matrix.python != 'pypy-3.8'
- name: Pypy tests
run: nox -s tests-pypy3
if: matrix.python == 'pypy-3.7'
if: matrix.python == 'pypy-3.8'
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
if: matrix.python == '3.11'
if: matrix.python == '3.12'
with:
files: ./coverage.xml
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
runs-on: 'ubuntu-latest'

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: 3.8
- name: Install python dependencies
run: python -m pip install -U pip nox
- name: Build and deploy
Expand Down
34 changes: 10 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,16 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: local
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
# Run the linter.
- id: ruff
exclude: ^tests
# Run the formatter.
- id: ruff-format
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
hooks:
- id: isort
name: isort
entry: poetry run isort ws tests
language: system
types:
- python
- id: black
name: black
entry: poetry run black ws tests
language: system
types:
- python
- id: bandit
name: bandit
entry: poetry run bandit -r ws
language: system
exclude: ^tests
types:
- python
- id: flake8
name: flake8
entry: poetry run flake8
language: system
types:
- python
5 changes: 5 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ version: 2
mkdocs:
configuration: mkdocs.yml

build:
os: "ubuntu-22.04"
tools:
python: "3.8"

python:
install:
- requirements: docs/requirements.txt
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
# Changelog

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.3.0] - 2023-11-24

### Changed

- Upgrade Pydantic to V2.

### Removed

- Drop support for Python 3.7

## [0.2.1] - 2023-02-12

### Security
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
![](https://github.com/lewoudar/ws/workflows/CI/badge.svg)
[![Coverage Status](https://codecov.io/gh/lewoudar/ws/branch/main/graphs/badge.svg?branch=main)](https://codecov.io/gh/lewoudar/ws)
[![Documentation Status](https://readthedocs.org/projects/pyws/badge/?version=latest)](https://pyws.readthedocs.io/en/latest/?badge=latest)
[![Code Style](https://img.shields.io/badge/code%20style-black-black)](https://github.com/lewoudar/ws)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/lewoudar/ws)
[![License Apache 2](https://img.shields.io/hexpm/l/plug.svg)](http://www.apache.org/licenses/LICENSE-2.0)

A simple yet powerful websocket cli.
Expand All @@ -28,14 +28,14 @@ or use a better package manager like [poetry](https://python-poetry.org/docs/):

```shell
# you probably want to add this dependency as a dev one, this is why I put -D into square brackets
$ poetry add [-D] websockets-cli
$ poetry add websockets-cli -G dev
```

ws starts working from **python3.7** and also supports **pypy3**. It has the following dependencies:
ws starts working from **python3.8** and also supports **pypy3**. It has the following dependencies:

- [trio](https://trio.readthedocs.io/en/stable/) for structured (async) concurrency support.
- [trio-websocket](https://trio-websocket.readthedocs.io/en/stable/) the library implementing the websocket protocol.
- [pydantic](https://pydantic-docs.helpmanual.io/) / [python-dotenv](https://pypi.org/project/python-dotenv/) for
- [pydantic](https://docs.pydantic.dev/latest/) / [pydantic-settings](https://docs.pydantic.dev/latest/concepts/pydantic_settings/) for
input validation and settings management.
- [certifi](https://pypi.org/project/certifi/) to manage TLS and certificates.
- [click](https://click.palletsprojects.com/en/8.1.x/) to write the cli.
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ A simple yet powerful websocket cli.

Each time I work on a web project involving websockets, I found myself wanting a simple (cli) tool to test what I have
coded. What I often do is to write a python script using [websockets](https://websockets.readthedocs.io/en/stable/).
There are graphical tools like [Postman](https://www.postman.com/), but I'm not confortable with.
There are graphical tools like [Postman](https://www.postman.com/), but I'm not conformable with.
So I decided to write a cli tool for this purpose.
6 changes: 3 additions & 3 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ or use a better package manager like [poetry](https://python-poetry.org/docs/):

```shell
# you probably want to add this dependency as a dev one, this is why I put -D into square brackets
$ poetry add [-D] websockets-cli
$ poetry add websockets-cli -G dev
```

ws starts working from **python3.7** and also supports **pypy3**. It has the following dependencies:
ws starts working from **python3.8** and also supports **pypy3**. It has the following dependencies:

- [trio](https://trio.readthedocs.io/en/stable/) for structured (async) concurrency support.
- [trio-websocket](https://trio-websocket.readthedocs.io/en/stable/) the library implementing the websocket protocol.
- [pydantic](https://pydantic-docs.helpmanual.io/) / [python-dotenv](https://pypi.org/project/python-dotenv/) for
- [pydantic](https://docs.pydantic.dev/latest/) / [pydantic-settings](https://docs.pydantic.dev/latest/concepts/pydantic_settings/) for
input validation and settings management.
- [certifi](https://pypi.org/project/certifi/) to manage TLS and certificates.
- [click](https://click.palletsprojects.com/en/8.1.x/) to write the cli.
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mkdocs-material==8.2.15
mkdocs-material==9.2.7
13 changes: 6 additions & 7 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@

nox.options.reuse_existing_virtualenvs = True

PYTHON_VERSIONS = ['pypy3', '3.7', '3.8', '3.9', '3.10', '3.11']
PYTHON_VERSIONS = ['pypy3', '3.8', '3.9', '3.10', '3.11', '3.12']
CI_ENVIRONMENT = 'GITHUB_ACTIONS' in os.environ


@nox.session(python=PYTHON_VERSIONS[-1])
def lint(session):
"""Performs pep8 and security checks."""
source_code = 'ws'
session.install('poetry>=1.0.0,<1.4.0')
session.install('poetry>=1.0.0,<1.5.0')
session.run('poetry', 'install', '--only', 'lint')
session.run('flake8', source_code)
session.run('ruff', 'check', source_code)
session.run('bandit', '-r', source_code)
session.run('black', source_code, 'tests', '--check')


@nox.session(python=PYTHON_VERSIONS[-1])
Expand All @@ -31,15 +30,15 @@ def safety(session):
@nox.session(python=PYTHON_VERSIONS)
def tests(session):
"""Runs the test suite."""
session.install('poetry>=1.0.0,<1.4.0')
session.install('poetry>=1.0.0,<1.5.0')
session.run('poetry', 'install', '--with', 'test')
session.run('pytest')


@nox.session(python=PYTHON_VERSIONS[-1])
def docs(session):
"""Builds the documentation."""
session.install('poetry>=1.0.0,<1.4.0')
session.install('poetry>=1.0.0,<1.5.0')
session.run('poetry', 'install', '--only', 'docs')
session.run('mkdocs', 'build', '--clean')

Expand All @@ -52,7 +51,7 @@ def deploy(session):
if 'POETRY_PYPI_TOKEN_PYPI' not in os.environ:
session.error('you must specify your pypi token api to deploy your package')

session.install('poetry>=1.0.0,<1.4.0')
session.install('poetry>=1.0.0,<1.5.0')
session.run('poetry', 'publish', '--build')


Expand Down
Loading

0 comments on commit bf0bb56

Please sign in to comment.