Skip to content

Conversation

kmvanbrunt
Copy link
Member

No description provided.

Copy link

codecov bot commented Jul 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.50%. Comparing base (0937472) to head (5dbd91f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1457      +/-   ##
==========================================
- Coverage   98.57%   98.50%   -0.07%     
==========================================
  Files          20       20              
  Lines        5749     5566     -183     
==========================================
- Hits         5667     5483     -184     
- Misses         82       83       +1     
Flag Coverage Δ
unittests 98.50% <100.00%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tleonhardt tleonhardt added this to the 3.0.0 milestone Jul 4, 2025

return statement

def _input_line_to_statement(self, line: str, *, orig_rl_history_length: Optional[int] = None) -> Statement:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot how much avoidable complexity macros added. Nice work surgically removing them. Everything here LGTM.

@kmvanbrunt kmvanbrunt merged commit acb824b into main Jul 4, 2025
32 of 33 checks passed
@kmvanbrunt kmvanbrunt deleted the remove_macros branch July 4, 2025 22:12
@pdalloz
Copy link
Contributor

pdalloz commented Jul 16, 2025

I see this is closed, so I guess there's no hope for macros?

I'm not sure where to put this comment, I posted the same thing in a discussion on macros and tab completion. I'll paste it here too, just to be sure you see it:

The great thing about macros for me is it lets my users create their own bespoke commands and toolkit.


Not sure if it's too late to chime in on macros. I find them very useful despite lack of autocomplete.
In pobshell I provide bash-like commands to explore live Python objects. https://github.com/pdalloz/pobshell

Some command can call sub-commands and it can get verbose, e.g. the find command can run a command string given by --cmd CMD on each matched object. I will work on improving syntax of the find command, but right now I'd be very sad to lose macros, they cut typing effort significantly

(I was planning to include macros in upcoming demo videos. Now I'm not sure what to do.)

Here is a list of my favourite macros. And I'm discovering new tricks all the time

gn name

  • find name somewhere in current object and give long listing of it
/ ▶ macro create gn find . --name {1}  -l  
/ ▶ gn get_names 
/cmd2/Cmd/get_names  function                  <function Cmd.get_names at 0x13b4104a0>

grep code pattern

  • find objects with code that matches pattern; list object details then relevant lines
/cmd2 ▶ macro create grep find --cat '*{1}*'  --cmd "ls -vl .;cat . | grep '{1}'"
/cmd2 ▶ grep get_names -L 3 .
/cmd2/Cmd  type                      <class 'cmd2.cmd2.Cmd'>
    def get_names(self) -> List[str]:
            for name in self.get_names()
            for name in self.get_names()
/cmd2/cmd2  module                    <module 'cmd2.cmd2' from '/opt/anaconda3/envs/PobEnv312all/lib/python3.12/site-pa…
    def get_names(self) -> List[str]:
            for name in self.get_names()
            for name in self.get_names()
/cmd2/Cmd/completenames  function                  <function Cmd.completenames at 0x13a5d8040>
        return [a[3:] for a in self.get_names() if a.startswith(dotext)]

for name-pattern pob-command

  • run pob-command on each object with matching name
/ ▶ macro create for find . --name {1} --cmd '{2}'
Macro 'for' overwritten
/ ▶ for get_names "cat -v1 ." 
/cmd2/Cmd/get_names      def get_names(self) -> List[str]:
/cmd2/cmd2/Cmd/get_names      def get_names(self) -> List[str]:

refs name

  • find name in source code, report objects referening it and show matching lines
    • differs from grep because it looks for name as a token; delimits search pattern with \b
  /PVi ▶ macro create refs find -r --cat '\b{1}\b' --cmd "ls -l .; cat -q . | grep -E '\b{1}\b'"
  Macro 'refs' overwritten
  /PVi ▶ refs TestCollector
  TestCollector  type                      <class 'pobshell.pobmain.Pobiverse.TestCollector'>
              self._pob = pob  # keep a reference to Pobiverse instance, so TestCollector can run scripts etc
  do_test  method                    <bound method Pobiverse.do_test of <pobshell.pobmain.Pobiverse object at 0x13e6cb320…
              self.test_collector = self.TestCollector(self, self.root, self.history)
              self.test_collector = self.TestCollector(self, self.root, self.history)

where name

  • find objects with name inside current object and enumerate the objects so they're easy to visit 'cd $N'
    NB stops searching after three matches
    NB Add additional options as required: -a, -d 6, --CODE, --map everything
/ ▶ macro create where find --name {1} -le -L 3
/ ▶ where cmd2
0: /pobmain/cmd2  module                    <module 'cmd2' from '/opt/anaconda3…
1: /pobshell/infocmds/cmd2  module                    <module 'cmd2' from '/opt…
2: /pobshell/pobmain/cmd2  module                    <module 'cmd2' from '/opt/…
/ ▶ cd $0
/pobmain/cmd2 ▶ 

+ pob-command (Macro called '+')

  • Run multiple ';'-separated pob-commands on each member of current object
  / ▶ macro create + find --cmd "{1}" -d 1
  Macro '+' created

  / ▶ + "ls -l . ; doc -1 .; cat -1 .; newline"
  /  PobNS                     /
  /  # Exploring use of Pobiverse with JSON
  
  feed  dict                      {'Schedule': {'conferences': [{'serial': 115}], 'events': [{'categories': ['Emerging La…
  
  fp  TextIOWrapper             <_io.TextIOWrapper name='/Users/peterdalloz/Dropbox/PYTHONDROPBOX/pobshell/Use_Cases/osco…
  fp  Character and line based layer over a BufferedIOBase object, buffer.
  
  json  module                    <module 'json' from '/opt/anaconda3/envs/PobEnv312all/lib/python3.12/json/__init__.py'>
  json  JSON (JavaScript Object Notation) <https://json.org> is a subset of
  json  r"""JSON (JavaScript Object Notation) <https://json.org> is a subset of
  
  sys  module                    <module 'sys' (built-in)>
  sys  This module provides access to some objects used or maintained by the

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants