Skip to content

Commit 04a3c72

Browse files
committed
addapt to ruamel changes in tabs reporting
1 parent 661fb0f commit 04a3c72

File tree

6 files changed

+78
-7
lines changed

6 files changed

+78
-7
lines changed

schema_salad/codegen.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@
1313
)
1414
from urllib.parse import urlsplit
1515

16-
1716
from . import schema
1817
from .codegen_base import CodeGenBase
1918
from .exceptions import SchemaSaladException
2019
from .java_codegen import JavaCodeGen
2120
from .python_codegen import PythonCodeGen
22-
from .typescript_codegen import TypeScriptCodeGen
2321
from .ref_resolver import Loader
2422
from .schema import shortname
23+
from .typescript_codegen import TypeScriptCodeGen
2524
from .utils import aslist
2625

2726
FIELD_SORT_ORDER = ["id", "class", "name"]

schema_salad/ref_resolver.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ def to_validation_exception(e: MarkedYAMLError) -> ValidationException:
9191

9292
if e.context:
9393
parent = ValidationException(e.context)
94-
mark = e.context_mark
95-
parent.file = re.sub(fname_regex, "", mark.name)
96-
parent.start = (mark.line + 1, mark.column + 1)
94+
context_mark = e.context_mark
95+
if context_mark:
96+
parent.file = re.sub(fname_regex, "", context_mark.name)
97+
parent.start = (context_mark.line + 1, context_mark.column + 1)
9798
parent.end = None
9899
parent.children = [exc]
99100
return parent

schema_salad/tests/test_cwl11.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from _pytest.tmpdir import TempPathFactory
1515

1616
from schema_salad.avro.schema import Names, SchemaParseException
17+
from schema_salad.exceptions import ValidationException
1718
from schema_salad.ref_resolver import Loader
1819
from schema_salad.schema import load_and_validate, load_schema
1920

@@ -64,3 +65,13 @@ def test_outputBinding(cwl_v1_2_schema: SchemaType) -> None:
6465
cwl_v1_2_schema, src="test_real_cwl/bio-cwl-tools/bamtools_stats.cwl"
6566
)
6667
print(f"the res:{res}")
68+
69+
70+
def test_yaml_tab_error(cwl_v1_2_schema: SchemaType) -> None:
71+
"""Tabs in the file."""
72+
with pytest.raises(
73+
ValidationException,
74+
match=r".+found\s+character\s+'\\t'\s+that\s+cannot\s+start\s+any\s+token$",
75+
):
76+
res = load_cwl(cwl_v1_2_schema, src="test_real_cwl/tabs_rna_seq_workflow.cwl")
77+
print(res)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
cwlVersion: v1.2
2+
class: Workflow
3+
4+
inputs:
5+
rna_reads_human: File
6+
ref_genome: Directory
7+
annotations: File
8+
9+
steps:
10+
quality_control:
11+
run: bio-cwl-tools/fastqc/fastqc_2.cwl
12+
in:
13+
reads_file: rna_reads_human
14+
out: [html_file]
15+
16+
mapping_reads:
17+
requirements:
18+
ResourceRequirement:
19+
ramMin: 9000
20+
run: bio-cwl-tools/STAR/STAR-Align.cwl
21+
in:
22+
RunThreadN: {default: 4}
23+
GenomeDir: ref_genome
24+
ForwardReads: rna_reads_human
25+
OutSAMtype: {default: BAM}
26+
SortedByCoordinate: {default: true}
27+
OutSAMunmapped: {default: Within}
28+
out: [alignment]
29+
30+
index_alignment:
31+
run: bio-cwl-tools/samtools/samtools_index.cwl
32+
in:
33+
bam_sorted: mapping_reads/alignment
34+
out: [bam_sorted_indexed]
35+
36+
count_reads:
37+
requirements:
38+
ResourceRequirement:
39+
ramMin: 500
40+
run: bio-cwl-tools/subread/featureCounts.cwl
41+
in:
42+
mapped_reads: index_alignment/bam_sorted_indexed
43+
annotations: annotations
44+
out: [featurecounts]
45+
46+
outputs:
47+
qc_html:
48+
type: File
49+
outputSource: quality_control/html_file
50+
bam_sorted_indexed:
51+
type: File
52+
outputSource: index_alignment/bam_sorted_indexed
53+
featurecounts:
54+
type: File
55+
outputSource: count_reads/featurecounts
56+

schema_salad/typescript_codegen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717

1818
import pkg_resources
1919

20-
from . import schema, _logger
20+
from . import _logger, schema
2121
from .codegen_base import CodeGenBase, TypeDef
2222
from .exceptions import SchemaException
23-
from .schema import shortname
2423
from .java_codegen import _ensure_directory_and_write, _safe_makedirs
24+
from .schema import shortname
2525

2626

2727
def doc_to_doc_string(doc: Optional[str], indent_level: int = 0) -> str:

typeshed/typing.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ class ItemsView(
402402
def __iter__(self) -> Iterator[Tuple[_KT_co, _VT_co]]: ...
403403
if sys.version_info >= (3, 8):
404404
def __reversed__(self) -> Iterator[Tuple[_KT_co, _VT_co]]: ...
405+
405406
def __or__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ...
406407
def __ror__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ...
407408
def __sub__(self, o: Iterable[Any]) -> Set[Tuple[_KT_co, _VT_co]]: ...
@@ -417,6 +418,7 @@ class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]):
417418
def __iter__(self) -> Iterator[_KT_co]: ...
418419
if sys.version_info >= (3, 8):
419420
def __reversed__(self) -> Iterator[_KT_co]: ...
421+
420422
def __or__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ...
421423
def __ror__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ...
422424
def __sub__(self, o: Iterable[Any]) -> Set[_KT_co]: ...
@@ -691,6 +693,7 @@ class NamedTuple(Tuple[Any, ...]):
691693
def _asdict(self) -> Dict[str, Any]: ...
692694
else:
693695
def _asdict(self) -> collections.OrderedDict[str, Any]: ...
696+
694697
def _replace(self: _T, **kwargs: Any) -> _T: ...
695698

696699
# Internal mypy fallback type for all typed dicts (does not exist at runtime)
@@ -714,6 +717,7 @@ def type_check_only(func_or_cls: _C) -> _C: ...
714717

715718
if sys.version_info >= (3, 7):
716719
from types import CodeType
720+
717721
class ForwardRef:
718722
__forward_arg__: str
719723
__forward_code__: CodeType

0 commit comments

Comments
 (0)