Skip to content

Commit 9e68b15

Browse files
wluptonmbj4668
authored andcommitted
Suppress unwanted errors
When there are multiple revisions of an imported module, they are all parsed, and the logic to suppress errors fails to suppress them from the revisions that aren't selected for import. This fix works around this.
1 parent a2065a1 commit 9e68b15

File tree

7 files changed

+37
-2
lines changed

7 files changed

+37
-2
lines changed

bin/pyang

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,9 @@ Validates the YANG module in <filename> (or stdin), and all its dependencies."""
450450
if etag in o.ignore_error_tags:
451451
continue
452452
if (ctx.implicit_errors is False and
453-
hasattr(epos.top, 'i_modulename') and
454453
epos.top.arg not in modulenames and
455-
epos.top.i_modulename not in modulenames and
454+
(not hasattr(epos.top, 'i_modulename') or
455+
epos.top.i_modulename not in modulenames) and
456456
epos.ref not in filenames):
457457
# this module was added implicitly (by import); skip this error
458458
# the code includes submodules

test/test_issues/test_i680/makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
test: test1
2+
3+
test1:
4+
-$(PYANG) --max-line-len=70 -f tree -o mod1.tree mod1.yang 2>&1 | diff mod1.expect -

test/test_issues/test_i680/mod1.expect

Whitespace-only changes.

test/test_issues/test_i680/mod1.tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
module: mod1
3+
augment /m2:a:
4+
+--rw b

test/test_issues/test_i680/mod1.yang

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module mod1 {
2+
yang-version 1.1;
3+
namespace "urn:mod1";
4+
prefix m1;
5+
6+
import mod2 {
7+
prefix m2;
8+
}
9+
10+
augment "/m2:a" {
11+
container b {}
12+
}
13+
}

test/test_issues/test_i680/mod2.yang

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mod2@2020-10-06.yang
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module mod2 {
2+
yang-version 1.1;
3+
namespace "urn:mod2";
4+
prefix m2;
5+
6+
revision 2020-10-06;
7+
8+
container a {
9+
description
10+
"This line is rather over-long, and therefore will trigger a warning with
11+
--max-line-length=70.";
12+
}
13+
}

0 commit comments

Comments
 (0)