mbj4668 / pyang

An extensible YANG validator and converter in python
ISC License
530 stars 342 forks source link

Warning "imported module not used" when using grouping #854

Closed sravaniregalla closed 8 months ago

sravaniregalla commented 1 year ago

Hi @fredgan

I am using PYANG of version 2.5.3. We get the following warnings from our yang modules when we use "--lint" option. [PYANG] WARNING a.yang:6 imported module "atype" not used

It looks like the problem is that we get this warning when the leaf (that uses the import) is inside a grouping.

Reproduce the issue with below example. atype.yang

module atype{
  prefix mt;
  namespace "urn:mt";

  typedef ttype{
    type uint8;
  }
}

a.yang

module a{
  prefix ma;
  namespace "urn:a";

  import atype{
    prefix ta;
  }

  grouping gg{
    leaf ga{
      description "leaf ga";
      type ta:ttype;
    }
  }

  container cc{
    uses gg;
  }
}

similar issue #718

fredgan commented 1 year ago

Please show me the command output: pyang --version and your python version as well.

and then, describe your WARNING operations.

sravaniregalla commented 1 year ago

You can refer the versions, here in this screenshot. versions

Warning Description:

  1. I am importing the module atype.yang at line no :6 in a.yang module.
  2. Here I am using that module inside a leaf(ga), which is present in grouping (gg) at line no: 12.
  3. Even though, Iam using at line no:12, Iam seeing the warning (a.yang:6: warning: imported module "atype" not used).
sravaniregalla commented 1 year ago

Hi @fredgan

Do you have time to look into this question? Do you think, is it a problem from pyang? If it could be a problem, when are you planning to solve?

BR Sravani Regalla

mbj4668 commented 8 months ago

The option --lint checks that the statements are in canonical order (see section 14 in RFC 7950), and due to the implementation when it finds a statement that is not in canonical order it doesn't consume it and thus it may lead to other errors reported.