Skip to content

Commit

Permalink
These are some typing and function-signature fixes that are required …
Browse files Browse the repository at this point in the history
…due to the new mypy 1.11.0 update. (#2851)
  • Loading branch information
ashleysommer authored Jul 24, 2024
1 parent bc53bf0 commit cc7e724
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
5 changes: 4 additions & 1 deletion rdflib/extras/infixowl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,10 @@ def subSumpteeIds(self): # noqa: N802
# predicate=RDFS.subClassOf,object=self.identifier):
# yield Class(s,skipOWLClassMembership=True)

def __repr__(self, full=False, normalization=True):
def __repr__(self):
return self.manchesterClass(full=False, normalization=True)

def manchesterClass(self, full=False, normalization=True): # noqa: N802
"""
Returns the Manchester Syntax equivalent for this class
"""
Expand Down
4 changes: 2 additions & 2 deletions test/test_extras/test_infixowl/test_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def test_class_getparents(graph):

assert list(sibling.subSumpteeIds()) == []

assert str(brother.__repr__(full=True)) == "Class: ex:Brother "
assert str(brother.manchesterClass(full=True)) == "Class: ex:Brother "

assert graph.serialize(format="ttl") == (
"@prefix ex: <http://example.org/vocab/> .\n"
Expand Down Expand Up @@ -251,7 +251,7 @@ def test_class_serialize(graph):

assert str(owlc.__invert__()) == "Some Class DisjointWith ( NOT ex:Sister )\n"

assert owlc.__repr__(full=True) == (
assert owlc.manchesterClass(full=True) == (
"Class: ex:test \n"
" ## A Defined Class (Man) ##\n"
" This is a Man\n"
Expand Down
3 changes: 2 additions & 1 deletion test/test_serializers/test_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,4 +717,5 @@ def test_serialize_to_fileuri_with_authortiy(
format=format.info.serializer,
)
assert False # this should never happen as serialize should always fail
assert catcher.value is not None
# type error, mypy thinks this line is unreachable, but it works fine
assert catcher.value is not None # type: ignore[unreachable, unused-ignore]
3 changes: 2 additions & 1 deletion test/test_sparql/test_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,4 +441,5 @@ def test_serialize_to_fileuri_with_authortiy(
encoding=encoding,
)
assert False # this should never happen as serialize should always fail
assert catcher.value is not None
# type error, mypy thinks this line is unreachable, but it works fine
assert catcher.value is not None # type: ignore[unreachable, unused-ignore]
5 changes: 3 additions & 2 deletions test/utils/test/test_outcome.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from contextlib import ExitStack
from typing import Any, Callable, NoReturn, Optional, Type, Union
from typing import Any, Callable, NoReturn, Optional, Type, Union, cast

import pytest

Expand All @@ -16,7 +16,8 @@ def _raise(
if isinstance(what, type) and issubclass(what, Exception):
raise what(*args, **kwargs)
elif callable(what):
raise what(*args, **kwargs)
what_fn: Callable[..., Exception] = cast(Callable[..., Exception], what)
raise what_fn(*args, **kwargs)


@pytest.mark.parametrize(
Expand Down

0 comments on commit cc7e724

Please sign in to comment.