Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/nmigen
base: 8b05b28f5a7c
Choose a base ref
...
head repository: m-labs/nmigen
compare: 75d0fcd639ae
Choose a head ref
  • 2 commits
  • 13 files changed
  • 1 contributor

Commits on Oct 26, 2019

  1. hdl.ir: allow disabling UnusedElaboratable warning in file scope.

    This warning is usually quite handy, but is problematic in tests:
    although it can be suppressed by using Fragment.get on elaboratable,
    that is not always possible, in particular when writing tests for
    exceptions raised by __init__, e.g.:
    
        def test_wrong_csr_bus(self):
            with self.assertRaisesRegex(ValueError, r"blah blah"):
                WishboneCSRBridge(csr_bus=object())
    
    In theory, it should be possible to suppress warnings per-module
    and even per-line using code such as:
    
        import re, warnings
        from nmigen.hdl.ir import UnusedElaboratable
        warnings.filterwarnings("ignore", category=UnusedElaboratable,
                                module=re.escape(__name__))
    
    Unfortunately, not only is this code quite convoluted, but it also
    does not actually work; we are using warnings.warn_explicit() because
    we collect source locations on our own, but it requires the caller
    to extract the __warningregistry__ dictionary from module globals,
    or warning suppression would not work. Not only is this not feasible
    in most diagnostic sites in nMigen, but also I never got it to work
    anyway, even when passing all of module, registry, and module_globals
    to warn_explicit().
    
    Instead, use a magic comment at the start of a file to do this job,
    which might not be elegant but is simple and practical. For now,
    only UnusedElaboratable can be suppressed with it, but in future,
    other linter parameters may become tweakable this way.
    whitequark committed Oct 26, 2019
    Configuration menu
    Copy the full SHA
    9786d0c View commit details
    Browse the repository at this point in the history
  2. test: use #nmigen: magic comment instead of monkey patch.

    Also, fix missing and incorrect src_loc_at arguments where
    appropriate so the testsuite passes without warnings.
    whitequark committed Oct 26, 2019
    Configuration menu
    Copy the full SHA
    75d0fcd View commit details
    Browse the repository at this point in the history