Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
naveen521kk committed Sep 11, 2024
1 parent f6f190b commit 2ad4081
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 16 deletions.
9 changes: 4 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
Expand All @@ -9,19 +9,18 @@ repos:
- id: mixed-line-ending
- id: check-merge-conflict
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 24.8.0
hooks:
- id: black
language_version: python3.11
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 7.1.1
hooks:
- id: flake8
additional_dependencies: [flake8-2020, flake8-implicit-str-concat]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
Expand Down
2 changes: 1 addition & 1 deletion manimpango/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
f"{os.environ['PATH']}"
)
try:
from .register_font import * # noqa: F403,F401
from .register_font import * # isort:skip # noqa: F403,F401
from .cmanimpango import * # noqa: F403,F401
from .enums import * # noqa: F403,F401
except ImportError as ie: # pragma: no cover
Expand Down
3 changes: 2 additions & 1 deletion manimpango/_register_font.pxd
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pango cimport *
from libc.stddef cimport wchar_t
from pango cimport *


cdef extern from "Python.h":
wchar_t* PyUnicode_AsWideCharString(
Expand Down
1 change: 0 additions & 1 deletion manimpango/_register_font.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,3 @@ cpdef list _list_fonts(tuple registered_fonts):
g_object_unref(fontmap)
family_list.sort()
return family_list

2 changes: 1 addition & 1 deletion manimpango/cmanimpango.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import typing
import warnings
from xml.sax.saxutils import escape

from . import registered_fonts
from .enums import Alignment
from .utils import *
from . import registered_fonts

include "utils.pxi"

Expand Down
2 changes: 1 addition & 1 deletion manimpango/pango.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ cdef extern from *:
return 1;
}
#endif
"""
# The above docs string is C which is used to
# check for the Pango Version there at run time.
Expand Down
4 changes: 2 additions & 2 deletions manimpango/register_font.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# -*- coding: utf-8 -*-
from __future__ import annotations

from functools import cache
from dataclasses import dataclass

from ._register_font import (
RegisteredFont,
_fc_register_font,
_fc_unregister_font,
_list_fonts,
_register_font,
_unregister_font,
RegisteredFont,
)

__all__ = [
Expand Down
3 changes: 2 additions & 1 deletion manimpango/utils.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ from _register_font cimport *

import warnings


cdef inline add_to_fontmap(PangoFontMap* fontmap, str font_path):
cdef GError *err = NULL
error_message = ""
Expand All @@ -11,7 +12,7 @@ cdef inline add_to_fontmap(PangoFontMap* fontmap, str font_path):
error_message = "Unknown error"
else:
error_message = err.message.decode('utf-8')

if not success:
warnings.warn(
f"Failed to add font at {font_path} to fontmap. Reason: {error_message}",
Expand Down
3 changes: 2 additions & 1 deletion tests/test_fonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ def test_adding_dummy_font(tmpdir):
dummy = tmpdir / "font.ttf"
with open(dummy, "wb") as f:
f.write(b"dummy")

assert not manimpango.register_font(str(dummy)), "Registered a dummy font?"


def test_simple_fonts_render(tmpdir):
filename = str(Path(tmpdir) / "hello.svg")
MarkupText("Hello World", filename=filename)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ def test_pango_version():
import manimpango

v = manimpango.pango_version()
assert type(v) == str
assert isinstance(v, str)


def test_cairo_version():
import manimpango

v = manimpango.cairo_version()
assert type(v) == str
assert isinstance(v, str)

0 comments on commit 2ad4081

Please sign in to comment.