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

chore: remove unused code (DEV-2950) #638

Merged
merged 8 commits into from
Nov 15, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ ignore_missing_imports = true # TODO: deac
show_column_numbers = true
strict = true
exclude = [
"src/dsp_tools/commands/xmlupload/models/value.py", # TODO: activate this
"src/dsp_tools/commands/xmlupload/models/permission.py", # TODO: activate this
"src/dsp_tools/commands/xmlupload/models/xmlresource.py", # TODO: activate this
"src/dsp_tools/models/helpers.py", # TODO: activate this
"src/dsp_tools/models/langstring.py", # TODO: activate this
"src/dsp_tools/commands/project/models/group.py", # TODO: activate this
Expand Down
8 changes: 3 additions & 5 deletions src/dsp_tools/commands/excel2xml/excel2xml_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
from lxml.builder import E # pylint: disable=no-name-in-module

from dsp_tools.commands.excel2xml.propertyelement import PropertyElement
from dsp_tools.commands.xmlupload.models.value import UriValue
from dsp_tools.models.exceptions import BaseError
from dsp_tools.models.helpers import DateTimeStamp
from dsp_tools.utils.shared import check_notna, simplify_name, validate_xml_against_schema
from dsp_tools.utils.uri_util import is_uri

xml_namespace_map = {None: "https://dasch.swiss/schema", "xsi": "http://www.w3.org/2001/XMLSchema-instance"}

Expand Down Expand Up @@ -1419,13 +1419,11 @@ def make_uri_prop(

# check value type
for val in values:
try:
UriValue(str(val.value))
except BaseError:
if not is_uri(str(val.value)):
raise BaseError(
f"Failed validation in resource '{calling_resource}', property '{name}': "
f"'{val.value}' is not a valid URI."
) from None
)

# make xml structure of the valid values
prop_ = etree.Element(
Expand Down
9 changes: 5 additions & 4 deletions src/dsp_tools/commands/xmlupload/models/permission.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# pylint: disable=missing-class-docstring,missing-function-docstring
from __future__ import annotations

from enum import Enum, unique
from typing import Optional, Union
Expand All @@ -14,7 +15,7 @@ class PermissionValue(Enum):
D = 8
CR = 16

def __str__(self):
def __str__(self) -> str:
tmp = {
1: "RV",
2: "V",
Expand All @@ -26,7 +27,7 @@ def __str__(self):


class Permissions:
_permissions: Union[dict[PermissionValue, list[str]], None]
_permissions: dict[PermissionValue, list[str]]

def __init__(self, permissions: Optional[dict[PermissionValue, list[str]]] = None):
if permissions is None:
Expand Down Expand Up @@ -57,7 +58,7 @@ def __str__(self) -> str:
tmpstr += str(permission) + " " + ",".join(groups)
return tmpstr

def add(self, key: PermissionValue, val: str):
def add(self, key: PermissionValue, val: str) -> None:
if self._permissions.get(key) is None:
self._permissions[key] = [val]
else:
Expand All @@ -72,7 +73,7 @@ def toJsonLdObj(self) -> str:
return tmpstr

@classmethod
def fromString(cls, permstr: str):
def fromString(cls, permstr: str) -> Permissions:
tmpstr = permstr.split("|")
permissions: dict[PermissionValue, list[str]] = {}
for s in tmpstr:
Expand Down