Skip to content

Commit 7b91a6d

Browse files
scastlarasdn4z
authored andcommitted
Merge branch 'main' into abstract-pkg-ref
2 parents b2ce530 + 1573c6a commit 7b91a6d

4 files changed

Lines changed: 72 additions & 58 deletions

File tree

.github/workflows/lgtm.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ jobs:
4141

4242
- name: Run LGTM Review
4343
run: |
44-
docker run --rm elementsinteractive/lgtm-ai \
44+
docker run --rm \
45+
-v "${{ github.workspace }}:/workspace" \
46+
-w /workspace \
47+
elementsinteractive/lgtm-ai \
4548
review \
4649
--pr-url "https://github.com/${{ github.repository }}/pull/${{ github.event.issue.number }}" \
4750
--git-api-key "${{ secrets.GITHUB_TOKEN }}" \

.github/workflows/preview-bump-version.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
container:
1111
image: commitizen/commitizen:4.8.3@sha256:08a078c52b368f85f34257a66e10645ee74d8cbe9b471930b80b2b4e95a9bd4a
1212

13-
name: "Bump version and create changelog with commitizen"
13+
name: "Preview next version"
1414
steps:
1515
- uses: actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b # v2.1.1
1616
id: app-token
@@ -22,7 +22,11 @@ jobs:
2222
fetch-depth: 0
2323
token: ${{ steps.app-token.outputs.token }}
2424
ref: ${{ github.head_ref }}
25+
- name: Configure git
26+
run: |
27+
git config --global --add safe.directory "*" # otherwise cz does not find .git/ directory
28+
2529
- id: cz
2630
name: Preview next version
2731
run: |
28-
cz bump --get-next
32+
cz bump --get-next

pyproject.toml

Lines changed: 58 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[project]
22
authors = [
3-
{name = "Daniel Sanz", email = "imsdn4z@gmail.com"},
4-
{name = "Sergio Castillo", email = "s.cast.lara@gmail.com"},
5-
{name = "Ludo van Orden"},
6-
{name = "Dmitrii Fedotov"},
3+
{ name = "Daniel Sanz", email = "imsdn4z@gmail.com" },
4+
{ name = "Sergio Castillo", email = "s.cast.lara@gmail.com" },
5+
{ name = "Ludo van Orden" },
6+
{ name = "Dmitrii Fedotov" },
77
]
88
maintainers = [
9-
{name = "Daniel Sanz", email = "imsdn4z@gmail.com"},
10-
{name = "Sergio Castillo", email = "s.cast.lara@gmail.com"},
9+
{ name = "Daniel Sanz", email = "imsdn4z@gmail.com" },
10+
{ name = "Sergio Castillo", email = "s.cast.lara@gmail.com" },
1111
]
1212
requires-python = "<4,>=3.9"
1313
dependencies = [
@@ -34,13 +34,7 @@ pattern = "v(?P<version>[^\\s]+)"
3434
packages = ["src/twyn"]
3535

3636
[tool.hatch.build.targets.sdist]
37-
include = [
38-
"/src",
39-
"/README.md",
40-
"/LICENSE",
41-
"/VERSION",
42-
"/pyproject.toml",
43-
]
37+
include = ["/src", "/README.md", "/LICENSE", "/VERSION", "/pyproject.toml"]
4438

4539
[project.scripts]
4640
twyn = "twyn.cli:entry_point"
@@ -53,13 +47,9 @@ dev = [
5347
"ruff<0.12.4,>=0.5.1",
5448
"types-requests<3.0.0.0,>=2.32.4.20250611",
5549
"types-python-dateutil>=2.9.0.20250809",
56-
"freezegun>=1.5.5",
57-
]
58-
local = [
59-
"ipdb<1.0.0,>=0.13.9",
60-
"commitizen<5.0,>=2.38",
61-
"pdbpp<1.0.0,>=0.11.6",
50+
"freezegun>=1.5.5",
6251
]
52+
local = ["ipdb<1.0.0,>=0.13.9", "commitizen<5.0,>=2.38", "pdbpp<1.0.0,>=0.11.6"]
6353

6454

6555
[build-system]
@@ -73,39 +63,39 @@ line-length = 120
7363
src = ["twyn", "tests"]
7464
[tool.ruff.lint]
7565
select = [
76-
"B", # flake8-bugbear
77-
"C", # mccabe
78-
"E", # pycodestyle
79-
"W", # pycodestyle warnings
80-
"F", # pyflakes
81-
"I", # isort
82-
"B", # bugbear
83-
"D", # pydocstyle
84-
"I", # isort
85-
"C4", # comprehensions
86-
"SIM", # simplify
87-
"N", # pep8-naming
88-
"TRY", # tryceratops
89-
"UP", # pyupgrade
90-
"PT", # pytest-style
91-
"TCH", # type-checking
92-
"PL", # pylint
93-
"G", # logging format
94-
"TID", # tidy-imports
66+
"B", # flake8-bugbear
67+
"C", # mccabe
68+
"E", # pycodestyle
69+
"W", # pycodestyle warnings
70+
"F", # pyflakes
71+
"I", # isort
72+
"B", # bugbear
73+
"D", # pydocstyle
74+
"I", # isort
75+
"C4", # comprehensions
76+
"SIM", # simplify
77+
"N", # pep8-naming
78+
"TRY", # tryceratops
79+
"UP", # pyupgrade
80+
"PT", # pytest-style
81+
"TCH", # type-checking
82+
"PL", # pylint
83+
"G", # logging format
84+
"TID", # tidy-imports
9585
]
9686
ignore = [
97-
"E501", # line-length (enforced by black instead)
98-
'D1', # pydocstyle enforces docstrings everywhere
99-
'TRY003', # tryceratops rule not useful
100-
"PLR0913", # pylint rule not useful
101-
"B008", # checks for function calls in default function arguments.
102-
'D206', # conflicts with formatter
103-
'W191', # conflicts with formatter
104-
'D203', # conflicts with formatter
105-
'D211', # conflicts with formatter
106-
'D212', # conflicts with formatter
107-
'UP031', # allow strings formated with %s
108-
'PLR2004' # magic value
87+
"E501", # line-length (enforced by black instead)
88+
'D1', # pydocstyle enforces docstrings everywhere
89+
'TRY003', # tryceratops rule not useful
90+
"PLR0913", # pylint rule not useful
91+
"B008", # checks for function calls in default function arguments.
92+
'D206', # conflicts with formatter
93+
'W191', # conflicts with formatter
94+
'D203', # conflicts with formatter
95+
'D211', # conflicts with formatter
96+
'D212', # conflicts with formatter
97+
'UP031', # allow strings formated with %s
98+
'PLR2004', # magic value
10999
]
110100

111101
[tool.ruff.lint.pydocstyle]
@@ -137,4 +127,21 @@ omit = ["tests/*"]
137127
fail_under = 95
138128
exclude_lines = ["if TYPE_CHECKING:", "pragma: no cover"]
139129

140-
130+
[tool.lgtm]
131+
categories = ["Correctness", "Quality", "Testing", "Security"]
132+
model = "gemini-2.5-pro"
133+
silent = false
134+
publish = true
135+
ai_retries = 2
136+
exclude = [
137+
"*.md",
138+
"poetry.lock",
139+
"uv.lock",
140+
"gradle.lockfile",
141+
"Podfile.lock",
142+
"Package.resolved",
143+
"Cartfile.resolved",
144+
"yarn.lock",
145+
"package-lock.json",
146+
"pnpm-lock.yaml",
147+
]

src/twyn/trusted_packages/references.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
import re
3-
from abc import abstractmethod
3+
from abc import ABC, abstractmethod
44
from datetime import datetime
55
from typing import Any, Union
66

@@ -18,13 +18,13 @@
1818
logger = logging.getLogger("twyn")
1919

2020

21-
class AbstractPackageReference:
21+
class AbstractPackageReference(ABC):
2222
"""Represents a reference from where to retrieve trusted packages.
2323
2424
It abstracts all the package-retrieval and caching logic.
2525
26-
It defines the `_parse` abstract method, so each subclass defines how to handle the feched data.
27-
It defines the `normalize_package` abstract method, so each subclass validates that the packages names are correct.
26+
It defines the `_parse` abstract method, so each subclass defines how to handle the fetched data.
27+
It defines the `normalize_packages` abstract method, so each subclass validates that the packages names are correct.
2828
"""
2929

3030
def __init__(self, source: str, cache_handler: Union[CacheHandler, None] = None) -> None:

0 commit comments

Comments
 (0)