Quellcode durchsuchen

Add pyright pre-commit hook

tags/v0.4
Ben Kurtovic vor 2 Monaten
Ursprung
Commit
06b08b30fa
4 geänderte Dateien mit 26 neuen und 11 gelöschten Zeilen
  1. +4
    -0
      .pre-commit-config.yaml
  2. +1
    -1
      LICENSE
  3. +14
    -0
      pyproject.toml
  4. +7
    -10
      src/earwigbot/wiki/copyvios/result.py

+ 4
- 0
.pre-commit-config.yaml Datei anzeigen

@@ -5,3 +5,7 @@ repos:
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.377
hooks:
- id: pyright

+ 1
- 1
LICENSE Datei anzeigen

@@ -1,4 +1,4 @@
Copyright (C) 2009-2017 Ben Kurtovic <ben.kurtovic@gmail.com>
Copyright (C) 2009-2024 Ben Kurtovic <ben.kurtovic@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal


+ 14
- 0
pyproject.toml Datei anzeigen

@@ -58,6 +58,20 @@ earwigbot = "earwigbot.cli:main"
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[tool.pyright]
exclude = [
# TODO
"src/earwigbot/commands",
"src/earwigbot/config",
"src/earwigbot/lazy.py",
"src/earwigbot/irc",
"src/earwigbot/tasks",
"src/earwigbot/wiki/copyvios"
]
pythonVersion = "3.11"
venvPath = "."
venv = "venv"

[tool.ruff]
target-version = "py311"



+ 7
- 10
src/earwigbot/wiki/copyvios/result.py Datei anzeigen

@@ -18,11 +18,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import urllib.parse
from threading import Event
from time import time

import urlparse

from earwigbot.wiki.copyvios.markov import EMPTY, EMPTY_INTERSECTION

__all__ = ["CopyvioSource", "CopyvioCheckResult"]
@@ -89,7 +88,7 @@ class CopyvioSource:
@property
def domain(self):
"""The source URL's domain name, or None."""
return urlparse.urlparse(self.url).netloc or None
return urllib.parse.urlparse(self.url).netloc or None

def start_work(self):
"""Mark this source as being worked on right now."""
@@ -182,13 +181,11 @@ class CopyvioCheckResult:
@property
def confidence(self):
"""The confidence of the best source, or 0 if no sources exist."""
return (
self.unified_confidence
if self.unified_confidence is not None
else self.best.confidence
if self.best
else 0.0
)
if self.unified_confidence is not None:
return self.unified_confidence
if self.best:
return self.best.confidence
return 0.0

@property
def url(self):


Laden…
Abbrechen
Speichern