Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: snok/install-poetry@v1.4.1
with:
# TODO: renovate
version: 1.8.2
- run: poetry build
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
env:
BUILD_PACKAGE: ${{ matrix.package }}
run: python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v4.3.0
Expand Down
64 changes: 32 additions & 32 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ default_install_hook_types:
- pre-commit

default_language_version:
python: python3.8
python: python3.9

repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v3.6.0
rev: v4.2.0
hooks:
- id: conventional-pre-commit
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v6.0.0
hooks:
- id: check-case-conflict
- id: check-executables-have-shebangs
Expand Down Expand Up @@ -46,7 +46,7 @@ repos:
exclude: tests/data/.*
- id: requirements-txt-fixer
- repo: https://github.com/PyCQA/pylint
rev: v3.2.7
rev: v3.3.8
hooks:
# TODO: pylint-import-modules support for pylint v3 (or alternative linter)
- id: pylint
Expand All @@ -73,47 +73,47 @@ repos:
- -d disallowed-name # TODO: fix
- -d unspecified-encoding # TODO: reevaluate
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5 # TODO: v1.5.2+ requires newer pre-commit, need to drop py3.8?
rev: v1.5.5
hooks:
- id: remove-crlf
- id: remove-tabs
exclude: 'Makefile'
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.14.0
rev: v3.15.0
hooks:
- id: reorder-python-imports
args: [--py38-plus]
args: [--py39-plus]
exclude: nonunicode/.*
- repo: https://github.com/asottile/pyupgrade
rev: v3.16.0
rev: v3.20.0
hooks:
- id: pyupgrade
args: [--py38-plus]
exclude: nonunicode/.*
- repo: https://github.com/asottile/add-trailing-comma
rev: v3.1.0
rev: v3.2.0
hooks:
- id: add-trailing-comma
exclude: nonunicode/.*
# TODO: add type hints
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.9.0
# hooks:
# - id: mypy
# require_serial: True
# language: python
# # N.B. mypy requires an installed version of whatever third-party
# # library it is asked to check against. In practice, that means
# # whenever we see an error telling us to do so, we should add the
# # relevant library to `additional_dependencies`.
# # Note that some libraries keep their type hints in packages named
# # `types-$lib` or `$lib-stubs`.
# additional_dependencies: []
# args:
# - --show-error-codes
# - --strict
# - --strict-equality
# - --warn-unreachable
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.17.1
hooks:
- id: mypy
require_serial: True
# N.B. mypy requires an installed version of whatever third-party
# library it is asked to check against. In practice, that means
# whenever we see an error telling us to do so, we should add the
# relevant library to `additional_dependencies`.
# Note that some libraries keep their type hints in packages named
# `types-$lib` or `$lib-stubs`.
additional_dependencies: ["types-requests", "types-pyyaml"]
args:
- --show-error-codes
- --strict-equality
- --warn-unreachable
- --ignore-missing-imports
# TODO: uncomment this arg after type hints improved
# - --strict
- repo: https://github.com/asottile/yesqa
rev: v1.5.0
hooks:
Expand All @@ -140,7 +140,7 @@ repos:
# - -iTRY301
# files: coveralls/.*
- repo: https://github.com/hhatto/autopep8
rev: v2.3.1
rev: v2.3.2
hooks:
- id: autopep8
args: [-a, -i, -p2]
Expand All @@ -153,7 +153,7 @@ repos:
- --ignore=D1,D203,D205,D212,D400,D401,D404,D407,D412,D413
files: coveralls/.*
- repo: https://github.com/PyCQA/flake8
rev: 7.1.2
rev: 7.3.0
hooks:
- id: flake8
language: python
Expand Down Expand Up @@ -194,7 +194,7 @@ repos:

# json
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.30.0
rev: 0.33.2
hooks:
- id: check-github-workflows
- id: check-renovate
Expand All @@ -204,7 +204,7 @@ repos:

# docker
- repo: https://github.com/AleksaC/hadolint-py
rev: v2.12.1-beta
rev: v2.12.1b3
hooks:
- id: hadolint
args:
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
<a name="4.1.1"></a>
## 4.1.1

#### Internal

* Use `httpx` to replace `requests`

<a name="4.1.0"></a>
## 4.1.0

#### BREAKING CHANGES

* Drop support for Python3.8

#### Internal

* Add type hints check to pre-commit config
* Only tests ``coverage`` v6.1.2+

<a name="4.0.1"></a>
## 4.0.1 (2024-05-15)

Expand Down
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
help:
@echo "Development makefile"
@echo
@echo "Usage: make <target>"
@echo "Targets:"
@echo " up Updates dev/test dependencies"
@echo " deps Ensure dev/test dependencies are installed"
@echo " check Checks that build is sane"
@echo " test Runs all tests"
@echo " style Auto-formats the code"
@echo " lint Auto-formats the code and check type hints"

up:
uv lock --upgrade

deps:
uv sync --all-extras --all-groups --inexact --verbose

_style:
$(MAKE) _check
style: deps _style

_check:
pre-commit run --all-files
check: deps _check

_lint:
$(MAKE) _check
lint: deps _lint

_test:
pytest
test: deps _test

_build:
rm -fR dist/
uv build
build: deps _build

ci: check _build _test
3 changes: 1 addition & 2 deletions coveralls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@

from .api import Coveralls


__version__ = importlib.metadata.version('coveralls')
__version__ = "4.1.1"
__all__ = ['Coveralls']
1 change: 0 additions & 1 deletion coveralls/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from .cli import main


if __name__ == '__main__':
main()
56 changes: 31 additions & 25 deletions coveralls/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
import re

import coverage
import requests
import httpx

from .exception import CoverallsException
from .git import git_info
from .reporter import CoverallReporter


log = logging.getLogger('coveralls.api')

NUMBER_REGEX = re.compile(r'(\d+)$', re.IGNORECASE)
Expand Down Expand Up @@ -96,9 +95,8 @@ def load_config_from_buildkite():

@staticmethod
def load_config_from_circle():
number = (
os.environ.get('CIRCLE_WORKFLOW_ID')
or os.environ.get('CIRCLE_BUILD_NUM')
number = os.environ.get('CIRCLE_WORKFLOW_ID') or os.environ.get(
'CIRCLE_BUILD_NUM',
)
pr = (os.environ.get('CI_PULL_REQUEST') or '').split('/')[-1] or None
job = os.environ.get('CIRCLE_NODE_INDEX')
Expand Down Expand Up @@ -250,6 +248,7 @@ def load_config_from_file(self):
with open(fname) as config:
try:
import yaml # pylint: disable=import-outside-toplevel

self.config.update(yaml.safe_load(config))
except ImportError:
log.warning(
Expand All @@ -275,24 +274,29 @@ def wear(self, dry_run=False):
return self.submit_report(json_string)

def submit_report(self, json_string):
endpoint = f'{self._coveralls_host.rstrip("/")}/api/v1/jobs'
endpoint = f"{self._coveralls_host.rstrip('/')}/api/v1/jobs"
verify = not bool(os.environ.get('COVERALLS_SKIP_SSL_VERIFY'))
response = requests.post(
endpoint, files={'json_file': json_string}, verify=verify,
response = httpx.post(
endpoint,
files={'json_file': json_string},
verify=verify,
)

if response.status_code == 422:
if self.config['service_name'].startswith('github'):
print(
'Received 422 submitting job via Github Actions. By '
'default, coveralls-python uses the "github" service '
'name, which requires you to set the $GITHUB_TOKEN '
'environment variable. If you want to use a '
'COVERALLS_REPO_TOKEN instead, please manually override '
'$COVERALLS_SERVICE_NAME to "github-actions". For more '
'info, see https://coveralls-python.readthedocs.io/en'
'/latest/usage/configuration.html#github-actions-support',
)
if response.status_code == 422 and self.config[
'service_name'
].startswith(
'github',
):
print(
'Received 422 submitting job via Github Actions. By '
'default, coveralls-python uses the "github" service '
'name, which requires you to set the $GITHUB_TOKEN '
'environment variable. If you want to use a '
'COVERALLS_REPO_TOKEN instead, please manually override '
'$COVERALLS_SERVICE_NAME to "github-actions". For more '
'info, see https://coveralls-python.readthedocs.io/en'
'/latest/usage/configuration.html#github-actions-support',
)

try:
response.raise_for_status()
Expand All @@ -319,9 +323,9 @@ def parallel_finish(self):
# Github Actions only
payload['repo_name'] = os.environ.get('GITHUB_REPOSITORY')

endpoint = f'{self._coveralls_host.rstrip("/")}/webhook'
endpoint = f"{self._coveralls_host.rstrip('/')}/webhook"
verify = not bool(os.environ.get('COVERALLS_SKIP_SSL_VERIFY'))
response = requests.post(endpoint, json=payload, verify=verify)
response = httpx.post(endpoint, json=payload, verify=verify)
try:
response.raise_for_status()
response = response.json()
Expand All @@ -331,8 +335,9 @@ def parallel_finish(self):
) from e

if 'error' in response:
e = response['error']
raise CoverallsException(f'Parallel finish failed: {e}')
raise CoverallsException(
f"Parallel finish failed: {response['error']}",
)

if 'done' not in response or not response['done']:
raise CoverallsException('Parallel finish failed')
Expand All @@ -358,7 +363,8 @@ def create_report(self):
log.debug('==\nReporting %s files\n==\n', len(data['source_files']))
for source_file in data['source_files']:
log.debug(
'%s - %d/%d', source_file['name'],
'%s - %d/%d',
source_file['name'],
sum(filter(None, source_file['coverage'])),
len(source_file['coverage']),
)
Expand Down
1 change: 0 additions & 1 deletion coveralls/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@

from .api import Coveralls


log = logging.getLogger('coveralls')


Expand Down
6 changes: 3 additions & 3 deletions coveralls/exception.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class CoverallsException(Exception):
# TODO: do we really need this?
def __eq__(self, other):
def __eq__(self, other) -> bool:
if isinstance(other, self.__class__):
return str(self) == str(other)
return False

def __ne__(self, other):
def __ne__(self, other) -> bool:
return not self.__eq__(other)

def __hash__(self):
def __hash__(self) -> int:
return hash(str(self))
Loading