Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update development tools: travis ci to github actions, tox to nox, nose to pytest #704

Merged
merged 19 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from 10 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
95 changes: 95 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions
# https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
#
# Needed GitHub Repository Secret:
# PYPI_PASSWORD - PyPI API token allowing write, release access to PyPI.
# Limit scope to just project.
# (See package.python.org example link above.)
pietermarsman marked this conversation as resolved.
Show resolved Hide resolved

name: On push
pietermarsman marked this conversation as resolved.
Show resolved Hide resolved

on:
push:

# If changing default-python be sure to change job "tests" matrix: include: also
env:
default-python: "3.10"

jobs:

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ env.default-python }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.default-python }}
- name: Upgrade pip, Install nox
run: |
python -m pip install --upgrade pip
python -m pip install nox
- name: Lint
run: |
nox --error-on-missing-interpreters --non-interactive --session lint

mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ env.default-python }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.default-python }}
- name: Upgrade pip, Install nox
run: |
python -m pip install --upgrade pip
python -m pip install nox
- name: Lint
pietermarsman marked this conversation as resolved.
Show resolved Hide resolved
run: |
nox --error-on-missing-interpreters --non-interactive --session mypy

tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
python-version: [ "3.6", "3.7", "3.8", "3.9", "3.10" ]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Persistent Github pip cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip${{ matrix.python-version }}
- name: Upgrade pip, Install nox
run: |
python -m pip install --upgrade pip
python -m pip install nox
- name: Execute Tests
run: |
nox --non-interactive --session tests-${{ matrix.python-version }}

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ env.default-python }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.default-python }}
- name: Upgrade pip, Install nox
run: |
python -m pip install --upgrade pip
python -m pip install nox
- name: Lint
pietermarsman marked this conversation as resolved.
Show resolved Hide resolved
run: |
nox --error-on-missing-interpreters --non-interactive --session docs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ tests/*.xml
tests/*.txt
.idea/
.tox/
.nox/

# python venv management tools
Pipfile
Expand Down
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Removed
- Unnecessary return statements without argument at the end of functions ([#707](https://github.com/pdfminer/pdfminer.six/pull/707))

### Changed
- Switched from nose to pytest, from tox to nox and from Travis CI to GitHub Actions ([#704](https://github.com/pdfminer/pdfminer.six/pull/704))

## [20211012]

### Added
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ Any contribution is appreciated! You might want to:
On all Python versions:

```sh
tox
nox
```

Or on a single Python version:

```sh
tox -e py36
nox -e py36
```
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,3 @@ $(CMAPDST)/to-unicode-Adobe-Japan1.pickle.gz: $(CMAPDST)
$(CMAPDST)/to-unicode-Adobe-Korea1.pickle.gz: $(CMAPDST)
$(CONV_CMAP) -c KSC-EUC=euc-kr -c KSC-Johab=johab -c KSCms-UHC=cp949 -c UniKS-UTF8=utf-8 \
$(CMAPDST) Adobe-Korea1 $(CMAPSRC)/cid2code_Adobe_Korea1.txt

test: cmap
nosetests
5 changes: 4 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ disallow_untyped_defs = True
[mypy-cryptography.hazmat.*]
ignore_missing_imports = True

[mypy-nose.*]
[mypy-pytest.*]
ignore_missing_imports = True

[mypy-setuptools]
ignore_missing_imports = True

[mypy-nox]
ignore_missing_imports = True
58 changes: 58 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import nox


PYTHON_ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"]


@nox.session
def lint(session):
session.install('flake8')
session.run(
'flake8',
'pdfminer/',
'tools/',
'tests/',
'--count',
'--statistics'
)


@nox.session
def mypy(session):
session.install('mypy')
session.run(
'mypy',
'--install-types',
'--non-interactive',
'--show-error-codes',
'.'
)


@nox.session(python=PYTHON_ALL_VERSIONS)
def tests(session):
session.install("-e", ".[dev]")
session.run('pytest')


@nox.session
def docs(session):
session.install("-e", ".[docs]")
session.run(
'python',
'-m',
'sphinx',
'-b',
'html',
'docs/source',
'docs/build/html'
)
session.run(
'python',
'-m',
'sphinx',
'-b',
'doctest',
'docs/source',
'docs/build/doctest'
)
5 changes: 3 additions & 2 deletions pdfminer/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os.path
import struct
from io import BytesIO
from typing import BinaryIO, Tuple
from typing import BinaryIO, Tuple, List, Any

from .jbig2 import JBIG2StreamReader, JBIG2StreamWriter
from .layout import LTImage
Expand Down Expand Up @@ -104,6 +104,7 @@ def export_image(self, image: LTImage) -> str:
# seems to be easily opened by other programs
from PIL import Image
raw_data = image.stream.get_rawdata()
assert raw_data is not None
ifp = BytesIO(raw_data)
i = Image.open(ifp)
i.save(fp, 'JPEG2000')
Expand Down Expand Up @@ -162,7 +163,7 @@ def is_jbig2_image(image: LTImage) -> bool:
return is_jbig2

@staticmethod
def jbig2_global(image):
def jbig2_global(image: LTImage) -> List[Any]:
global_streams = []
filters = image.stream.get_filters()
for filter_name, params in filters:
Expand Down
10 changes: 7 additions & 3 deletions pdfminer/pdfdocument.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from . import settings
from .arcfour import Arcfour
from .pdfparser import PDFSyntaxError, PDFParser, PDFStreamParser
from .pdftypes import DecipherCallable, PDFException, PDFTypeError, PDFStream, \
PDFObjectNotFound, decipher_all, int_value, str_value, list_value, \
uint_value, dict_value, stream_value
from .pdftypes import DecipherCallable, PDFException, PDFTypeError, \
PDFStream, PDFObjectNotFound, decipher_all, int_value, str_value, \
list_value, uint_value, dict_value, stream_value
from .psparser import PSEOF, literal_name, LIT, KWD
from .utils import choplist, nunpack, decode_text

Expand Down Expand Up @@ -44,6 +44,10 @@ class PDFEncryptionError(PDFException):
pass


class PDFPasswordIncorrect(PDFEncryptionError):
pass


class PDFEncryptionWarning(UserWarning):
"""Legacy warning for failed decryption.

Expand Down
2 changes: 1 addition & 1 deletion pdfminer/pdftypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def stream_value(x: object) -> "PDFStream":
return x


def decompress_corrupted(data):
def decompress_corrupted(data: bytes) -> bytes:
"""Called on some data that can't be properly decoded because of CRC checksum
error. Attempt to decode it skipping the CRC.
"""
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import sys
from pathlib import Path

from setuptools import setup
from os import path

sys.path.append(str(Path(__file__).parent))
import pdfminer as package


Expand All @@ -17,7 +21,7 @@
'cryptography',
],
extras_require={
"dev": ["nose", "tox", "mypy == 0.910"],
"dev": ["pytest", "nox", "mypy == 0.931"],
"docs": ["sphinx", "sphinx-argparse"],
},
description='PDF parser and analyzer',
Expand Down
Loading