mirror of https://github.com/dethos/inlinehashes
add linter job to the CI
This commit is contained in:
parent
a916ea14e6
commit
65889f83a3
|
@ -15,7 +15,7 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Set up Python 3.11
|
- name: Set up Python 3.11
|
||||||
uses: actions/setup-python@v3
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: "3.11"
|
python-version: "3.11"
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
@ -27,12 +27,29 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
poetry run black --check .
|
poetry run black --check .
|
||||||
|
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Set up Python 3.11
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: "3.11"
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install poetry
|
||||||
|
poetry install
|
||||||
|
- name: Check code with ruff
|
||||||
|
run: |
|
||||||
|
poetry run ruff .
|
||||||
|
|
||||||
typing:
|
typing:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Set up Python 3.11
|
- name: Set up Python 3.11
|
||||||
uses: actions/setup-python@v3
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: "3.11"
|
python-version: "3.11"
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
|
|
@ -19,7 +19,7 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v3
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
|
|
@ -4,12 +4,13 @@ This file contains all the logic for the command line interface of
|
||||||
this library. It makes use of the same tools available for those that
|
this library. It makes use of the same tools available for those that
|
||||||
install the package in order to be used programatically.
|
install the package in order to be used programatically.
|
||||||
"""
|
"""
|
||||||
from typing import List
|
|
||||||
from urllib.request import urlopen, Request
|
|
||||||
from urllib.error import URLError
|
|
||||||
import argparse
|
import argparse
|
||||||
import inlinehashes
|
|
||||||
import json
|
import json
|
||||||
|
from typing import List
|
||||||
|
from urllib.error import URLError
|
||||||
|
from urllib.request import Request, urlopen
|
||||||
|
|
||||||
|
import inlinehashes
|
||||||
|
|
||||||
|
|
||||||
def build_output(
|
def build_output(
|
||||||
|
|
|
@ -4,12 +4,12 @@ This small module helps you to parse HTML documents and extract all the inline
|
||||||
content that must be specifically allowed in the Content-Security-Policy in
|
content that must be specifically allowed in the Content-Security-Policy in
|
||||||
order to work (assuming "unsafe-inline" is not present).
|
order to work (assuming "unsafe-inline" is not present).
|
||||||
"""
|
"""
|
||||||
from typing import List, Callable, Optional
|
import base64
|
||||||
|
import hashlib
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from functools import cached_property, partial
|
from functools import cached_property, partial
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
import hashlib
|
from typing import Callable, List, Optional
|
||||||
import base64
|
|
||||||
|
|
||||||
from bs4 import BeautifulSoup, Tag # type: ignore
|
from bs4 import BeautifulSoup, Tag # type: ignore
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class Inline:
|
||||||
return f"sha512-{h_b64}"
|
return f"sha512-{h_b64}"
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f"Inline(content='{self.content}', line='{self.line}', postiion='{self.position}')"
|
return f"Inline(line='{self.line}', position='{self.position}')"
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f"Inline(content='{self.short_content}...')"
|
return f"Inline(content='{self.short_content}...')"
|
||||||
|
|
|
@ -251,6 +251,32 @@ pluggy = ">=0.12,<2.0"
|
||||||
[package.extras]
|
[package.extras]
|
||||||
testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"]
|
testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ruff"
|
||||||
|
version = "0.0.229"
|
||||||
|
description = "An extremely fast Python linter, written in Rust."
|
||||||
|
category = "dev"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
files = [
|
||||||
|
{file = "ruff-0.0.229-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:35635bfd375a50f67c5f7c6c3f7950e70c903ad784467fa464581d2ee5c8fcc1"},
|
||||||
|
{file = "ruff-0.0.229-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:541822bf00016fd35415d35f4e8a03ebf94089525faac40a03ec00f6eebac2df"},
|
||||||
|
{file = "ruff-0.0.229-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:52c0a7155843fa24fbdde06b98f8725da26dcd9a71ca334f4a15502ae5ea34b5"},
|
||||||
|
{file = "ruff-0.0.229-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:0ded94f1243ac39b8f89b1b6e80baa04b772628e01619ccf4a883d597debf9b2"},
|
||||||
|
{file = "ruff-0.0.229-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7ce98074164b3660260dc871804bfd8c22f8b5971063e6817d3e68178344624b"},
|
||||||
|
{file = "ruff-0.0.229-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:a042de7a8da6a7f016ba9fe747697df21cf905179602a9282e52b99a2520c2bd"},
|
||||||
|
{file = "ruff-0.0.229-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e39f78c0b115f9228297f25e653dcbdaa6c93ec3577c3b6839519c1b08012780"},
|
||||||
|
{file = "ruff-0.0.229-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6910ac9bfc76e90d234ceed4b2b30a7955ae1783b696f4bf3476de583e0b5efa"},
|
||||||
|
{file = "ruff-0.0.229-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eee7012303ed04a23210badba6a40da8372b8d5dd79d686831c3d1019dbe949f"},
|
||||||
|
{file = "ruff-0.0.229-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:2fef23a28988275669838d23743a4ba281088d46ad53b6a6a72536b7b90fe3dd"},
|
||||||
|
{file = "ruff-0.0.229-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:9b3eeedd031f3713e947c22206e0965f6770780774802aff77fd1862f0fdc261"},
|
||||||
|
{file = "ruff-0.0.229-py3-none-musllinux_1_2_i686.whl", hash = "sha256:71d74a4da455bfa3162aaa6a6eb55028f301739b4f69b5cd16a6e5ea2c0c2544"},
|
||||||
|
{file = "ruff-0.0.229-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:1f3f95a2575d12a92b5a898fc54c6ec969497b167fec018a28a8f066fc1c9c1f"},
|
||||||
|
{file = "ruff-0.0.229-py3-none-win32.whl", hash = "sha256:24c064bffc9b86408ded1e482fb99b06935d1b653959a3b152bd0402fc85775e"},
|
||||||
|
{file = "ruff-0.0.229-py3-none-win_amd64.whl", hash = "sha256:9d72db5d2402fd59d50acb599e4fc3c3d9c68fb325f9af8c06e1adc73c29746d"},
|
||||||
|
{file = "ruff-0.0.229.tar.gz", hash = "sha256:ad151359e5194f6e7a987bdefbab7da733bbcddbe99b8b77beca74b0e216b8bc"},
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "soupsieve"
|
name = "soupsieve"
|
||||||
version = "2.3.2.post1"
|
version = "2.3.2.post1"
|
||||||
|
@ -278,4 +304,4 @@ files = [
|
||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.11"
|
python-versions = "^3.11"
|
||||||
content-hash = "85c89d2603d89427b85781eb0e88c9bb99bcf620ebde1a6e661503bba3797835"
|
content-hash = "0df57fe5eed6559a07fde2ce7470a34e0b6e0e0c897a1a848daa92287217037f"
|
||||||
|
|
|
@ -26,10 +26,15 @@ beautifulsoup4 = "^4.10.0"
|
||||||
pytest = "^7.2.1"
|
pytest = "^7.2.1"
|
||||||
black = "^22.1.0"
|
black = "^22.1.0"
|
||||||
mypy = "^0.991"
|
mypy = "^0.991"
|
||||||
|
ruff = "^0.0.229"
|
||||||
|
|
||||||
[tool.poetry.scripts]
|
[tool.poetry.scripts]
|
||||||
inlinehashes = "inlinehashes.app:run_cli"
|
inlinehashes = "inlinehashes.app:run_cli"
|
||||||
|
|
||||||
|
[tool.ruff]
|
||||||
|
select = ["E", "F", "I"]
|
||||||
|
line-length=88
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core>=1.0.0"]
|
requires = ["poetry-core>=1.0.0"]
|
||||||
build-backend = "poetry.core.masonry.api"
|
build-backend = "poetry.core.masonry.api"
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
from inlinehashes import __version__, parse
|
from inlinehashes import __version__, parse
|
||||||
from inlinehashes.lib import Inline, _EVENT_HANDLER_ATTRS
|
from inlinehashes.lib import _EVENT_HANDLER_ATTRS, Inline
|
||||||
|
|
||||||
|
|
||||||
class TestInline:
|
class TestInline:
|
||||||
|
|
Loading…
Reference in New Issue