banesullivan / scooby

🐶 🕵️ Great Dane turned Python environment detective
MIT License
47 stars 12 forks source link

Enable __add__ and __contains__ for Report #97

Closed banesullivan closed 12 months ago

banesullivan commented 1 year ago

Was playing around with some reports and realized this might be a useful feature

>>> from scooby import Report as R
>>> a = R(['numpy', 'matplotlib'], optional=[])
>>> b = R(['localtileserver'], optional=[])
>>> a

--------------------------------------------------------------------------------
  Date: Wed Sep 28 23:49:15 2022 MDT

                OS : Darwin
            CPU(s) : 12
           Machine : x86_64
      Architecture : 64bit
               RAM : 32.0 GiB
       Environment : Python
       File system : apfs

  Python 3.8.12 | packaged by conda-forge | (default, Oct 12 2021, 21:50:38)
  [Clang 11.1.0 ]

             numpy : 1.23.3
        matplotlib : Module not found
--------------------------------------------------------------------------------
>>> b

--------------------------------------------------------------------------------
  Date: Wed Sep 28 23:49:16 2022 MDT

                OS : Darwin
            CPU(s) : 12
           Machine : x86_64
      Architecture : 64bit
               RAM : 32.0 GiB
       Environment : Python
       File system : apfs

  Python 3.8.12 | packaged by conda-forge | (default, Oct 12 2021, 21:50:38)
  [Clang 11.1.0 ]

   localtileserver : Module not found
--------------------------------------------------------------------------------
>>> a + b

--------------------------------------------------------------------------------
  Date: Wed Sep 28 23:49:20 2022 MDT

                OS : Darwin
            CPU(s) : 12
           Machine : x86_64
      Architecture : 64bit
               RAM : 32.0 GiB
       Environment : Python
       File system : apfs

  Python 3.8.12 | packaged by conda-forge | (default, Oct 12 2021, 21:50:38)
  [Clang 11.1.0 ]

             numpy : 1.23.3
        matplotlib : Module not found
   localtileserver : Module not found
--------------------------------------------------------------------------------

This also adds support for __contains__:

>>> 'numpy' in a
True
codecov-commenter commented 1 year ago

Codecov Report

Merging #97 (7f8ea89) into main (abe414d) will increase coverage by 0.35%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #97      +/-   ##
==========================================
+ Coverage   87.23%   87.59%   +0.35%     
==========================================
  Files           4        4              
  Lines         384      395      +11     
==========================================
+ Hits          335      346      +11     
  Misses         49       49