Skip to content

Commit

Permalink
Merge pull request #283 from RDFLib/base_uri_relative
Browse files Browse the repository at this point in the history
Base uri relative
  • Loading branch information
ashleysommer authored Jan 24, 2025
2 parents c4dd765 + c637f50 commit 93d9f7b
Show file tree
Hide file tree
Showing 18 changed files with 257 additions and 110 deletions.
39 changes: 20 additions & 19 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 14 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ http = [
"sanic-cors==2.2.0"
]
dev-lint = [
"ruff>=0.1.5",
"ruff>=0.9.1",
"black==24.3.0",
"platformdirs"
]
Expand Down Expand Up @@ -120,7 +120,7 @@ include = [
pytest = "^7.2"
coverage = {version=">6,<7,!=6.0.*,!=6.1,!=6.1.1", optional=true}
pytest-cov = {version="^2.8.1", optional=true}
ruff = {version="^0.1.5", optional=true}
ruff = {version="^0.9.1", optional=true}
black = {version="24.3.0", optional=true}
mypy = {version=">=1.13.0", optional=true}
types-setuptools = {version="*", optional=true}
Expand Down Expand Up @@ -160,13 +160,6 @@ exclude = '''
'''

[tool.ruff]
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
select = ["E", "F"]
ignore = ["E501"] # Turn off ruff's too-long-line detection for now, we'll have to enable it again later.

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
unfixable = []

# Exclude a variety of commonly ignored directories.
exclude = [
Expand Down Expand Up @@ -196,17 +189,26 @@ exclude = [
"node_modules",
"venv",
]

# Same as Black.
line-length = 119

[lint]
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
select = ["E", "F"]
ignore = ["E501"] # Turn off ruff's too-long-line detection for now, we'll have to enable it again later.

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
unfixable = []
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.mccabe]

[lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10

[tool.ruff.pycodestyle]
[lint.pycodestyle]
ignore-overlong-task-comments = true

[tool.pytest.ini_options]
Expand Down
11 changes: 8 additions & 3 deletions pyshacl/extras/js/loader.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#
#
import typing
from pathlib import Path
from urllib import request

from pyshacl.rdfutil.load import path_from_uri

try:
import regex
except ImportError:
Expand Down Expand Up @@ -38,9 +41,11 @@ def get_js_from_web(url: str):


def get_js_from_file(filepath: str):
if filepath.startswith("file://"):
filepath = filepath[7:]
f = open(filepath, "rb")
if filepath.startswith("file:"):
_file_path = path_from_uri(filepath)
else:
_file_path = Path(filepath)
f = open(_file_path, "rb")
return f


Expand Down
Loading

0 comments on commit 93d9f7b

Please sign in to comment.