Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
exclude = unidiff/__init__.py

25 changes: 25 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Lint and type check

on:
pull_request:
branches:
- main

jobs:
lint-and-type-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: '3.11'

- name: Install flake8 and mypy
run: pip install flake8 mypy

- name: Run flake8
run: flake8 unidiff

- name: Run mypy
run: mypy unidiff
18 changes: 18 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Run tests

on:
pull_request:
branches:
- main

jobs:
lint-and-type-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: '3.11'
- run:
./run_tests.sh
6 changes: 6 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
History
-------

0.7.7 - 2025-03-09
------------------

* Drop Python2 support
* Fixed an ImportError of version in init file after changes in the project structure

0.7.6 - 2025-03-09
------------------

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "unidiff2"
version = "0.7.6"
version = "0.7.7"
description = "Unified diff parsing/metadata extraction library."
readme = {file = "README.rst", content-type = "text/x-rst"}
keywords = ["unified", "diff", "parse", "metadata"]
Expand Down
11 changes: 3 additions & 8 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@
import unittest

from unidiff import PatchSet
from unidiff.patch import PY2
from unidiff.errors import UnidiffParseError

if not PY2:
unicode = str
unicode = str


class TestUnidiffParser(unittest.TestCase):
"""Tests for Unified Diff Parser."""
Expand All @@ -52,11 +51,7 @@ def test_missing_encoding(self):
utf8_file = os.path.join(self.samples_dir, 'samples/sample3.diff')
# read bytes
with open(utf8_file, 'rb') as diff_file:
if PY2:
self.assertRaises(UnicodeDecodeError, PatchSet, diff_file)
else:
# unicode expected
self.assertRaises(TypeError, PatchSet, diff_file)
self.assertRaises(TypeError, PatchSet, diff_file)

def test_encoding_param(self):
utf8_file = os.path.join(self.samples_dir, 'samples/sample3.diff')
Expand Down
2 changes: 0 additions & 2 deletions unidiff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

from __future__ import unicode_literals

from unidiff import __version__
from unidiff.patch import (
DEFAULT_ENCODING,
LINE_TYPE_ADDED,
Expand All @@ -38,4 +37,3 @@
UnidiffParseError,
)

VERSION = __version__.__version__
5 changes: 4 additions & 1 deletion unidiff/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@
RE_BINARY_DIFF = re.compile(
r'^Binary files? '
r'(?P<source_filename>[^\t]+?)(?:\t(?P<source_timestamp>[\s0-9:\+-]+))?'
r'(?: and (?P<target_filename>[^\t]+?)(?:\t(?P<target_timestamp>[\s0-9:\+-]+))?)? (differ|has changed)')
r'(?: and (?P<target_filename>[^\t]+?)'
r'(?:\t(?P<target_timestamp>[\s0-9:\+-]+))?)'
r'? (differ|has changed)'
)

RE_PATCH_FILE_PREFIX = re.compile(r"^[abciow12]/.*$")

Expand Down
Loading