An error occurred fetching the project authors.
  1. 23 Sep, 2024 1 commit
  2. 19 Dec, 2022 1 commit
    • Jérome Perrin's avatar
      *: rewrite with lib2to3.fixes.fix_asserts and ad-hoc assertin · 2e366054
      Jérome Perrin authored
      The add-hoc assertin filter:
      
      --
      
      from typing import List
      
      import lib2to3
      
      from lib2to3.fixer_base import BaseFix
      from lib2to3.fixer_util import Comma, Name
      
      class FixAssertIn(BaseFix):
      
        PATTERN = """
            power< any+ trailer< '.' meth=("assertTrue" | "assertFalse")>
            trailer< '('
              comparison< (needle=any ( comp_op<'not' 'in'> | 'in' ) haystack=any) >
            ')' > >
        """
      
        def transform(self, node: lib2to3.pytree.Node,
                      results: List[lib2to3.pytree.Base]):
      
          needle = results['needle']
          haystack = results['haystack']
          meth = results["meth"][0]
      
          method_map = {True: 'assertIn', False: 'assertNotIn'}
          method_in = meth.value == 'assertTrue'
          if 'not' in str(needle.parent.children[1]):
            method_in = not method_in
          meth.replace(Name(method_map[method_in], prefix=meth.prefix))
      
          needle.parent.children = [needle, Comma(), haystack]
      2e366054
  3. 30 Sep, 2022 1 commit
  4. 06 Mar, 2018 1 commit
  5. 06 Oct, 2011 1 commit
  6. 19 Nov, 2010 2 commits
  7. 05 Nov, 2010 1 commit
  8. 27 Jan, 2010 1 commit
  9. 17 Dec, 2009 1 commit
  10. 15 Dec, 2009 1 commit
  11. 11 Dec, 2009 1 commit
  12. 16 Nov, 2009 1 commit
  13. 13 Nov, 2009 1 commit
  14. 09 Nov, 2009 1 commit
  15. 25 Oct, 2009 2 commits
  16. 16 Sep, 2008 2 commits
  17. 27 Sep, 2006 2 commits
  18. 25 Mar, 2006 1 commit
  19. 22 Feb, 2006 1 commit
  20. 16 Feb, 2006 1 commit
  21. 08 Feb, 2004 1 commit
  22. 10 Dec, 2002 1 commit