Skip to content

Resolve Ruff TODOs - #8

Open
Avasam wants to merge 1 commit into
Kalmat:masterfrom
Avasam:resolve-Ruff-TODOs
Open

Resolve Ruff TODOs#8
Avasam wants to merge 1 commit into
Kalmat:masterfrom
Avasam:resolve-Ruff-TODOs

Conversation

@Avasam

@Avasam Avasam commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread ruff.toml
Comment on lines 46 to 47
# TODO: Add and configure isort (I) first
"RUF022",

@Avasam Avasam Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

About this TODO still left.

A thing with Ruff import sorting https://docs.astral.sh/ruff/settings/#lintisort
Is that Ruff doesn't support your current import style. (I believe the original isort would: https://isort.readthedocs.io/en/latest/configuration/multi_line_output_modes.html )

Image

If you like or don't mind that style, I can add it so you get consistent import sorting without any additional tooling.
If you don't like it and would rather keep your current style, I'll take note of it and update this comment. And I'll separately suggest the original isort tool.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Sorry for my late reply. I've been out for some weeks.

To be honest, I have no preferences at all. Very likely this is a mistake of mine, but I don't pay much attention to coding style, generally speaking. On the other hand, I am totally aware that a minimum of "style" is necessary in case others want to understand and/or modify the code.

This leads me to another comment of yours regarding formatters and autofixers. I have seen there is some "debate" on that, and it was funny to me that in some cases there was like a division between "old" and "young" coders... hahahaha!

I played around a little with autopep8... it's fine, but things like these look very weird to me:

        windows: list[str] = (str(ret[8:-2]).replace("[",
                                                     "").replace("]",
                                                                 "").replace("},{",
                                                                             "}|&|{").split("|&|"))
    x1, y1, w1, h1 = box1 if isinstance(
        box1, tuple) else (
        box1.left, box1.top, box1.width, box1.height)
    x2, y2, w2, h2 = box2 if isinstance(
        box2, tuple) else (
        box2.left, box2.top, box2.width, box2.height)

In short, do whatever you consider... I have no preferences, and this way I can learn a more modern and common styling.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think I will use this style from now on:

#include <X11/Xlib.h>
char *l="dbcefcbddabcddcba~WAB+  +BAW~              +-84HLSU?A6J57IKJT576,",
*F="          ,>>,>  xl~w/?  ,>>>,s  m\177>>\177\177  mm2>>>  >uk>>> ",*f;y,u;
#define v for (i=0,b=0;b>511?b=0,i+=64:0,i<512;b+=64) A=i/64*10+b/64+21,XCopy\
Plane(d, r[I[A]+7+14*(i+b>>6&1)+28*(A==z)],w,C,0,0,64,64,b,i,1); XFlush(d);
#define _(a) *f++=a&*F?-(z%14<7):"U\252U\0DDDD"[z/14*2|u&1],
#define G(p) p##Pixel(d,DefaultScreen(d))
#define R(a) |(a==O|p==a)*
#define P return y=~y,
#define a X(0,0,0,
#define H while(
#define D ;if(

long
I[304],b,i,z;main(x,W)                   char**W; { Display *d =
 XOpenDisplay(""); Window               w = XCreateSimpleWindow
  (d, DefaultRootWindow(d),            64,64,512,512,2,G(Black)
   ,G(Black)); XGCValues g;           XButtonEvent e; long A,r
    [56],Z,* m = I , C ,Y;           XSelectInput(d,w,32772);
     XMapWindow( d, w); g.          foreground = G(White);
      C=XCreateGC(d,w,4,&g);       F+=48; H f=I,i=0,z<56){
       H u=0,i++<8){ H _(0)_(     64)_(16)_(8)_(4)_(2)_(1
       )_(0)++u<8); F++; } F-=   z%7-6?z%14<6?16:0:8; r[
        z++]=XCreateBitmapFromData(d,w,I,64,64); } srand(
       time(z=u=0)); H I[z]=-(   z>98|z<21|(z+1)%10<2),
      ++z<120); H ++m<9+I) 80     [m]=-2,90[m]=~(20[m]=7&*
     l++),30[m]=1; D 1<x) Z=       *W[1]-45; D 2<x){ a u,1
   ,Z); a u,0,1); z=0; } H          1){ XNextEvent(d,&e); D
  e.type==12){ v } D e.              type==4){ b=e.y/64*10+e
.x/64+21; D(b[I]^y)<-1)               { z=b; v} else{ i=(b<29
|b>90)&((z[I]^y)==-2)?-                6^y:z[I]; Y=y; a u,0,1);
z=0; v D 1<x&&Y-y){ a u                ,1,Z); a u,0,1); } z=0;
        v } } } }


                             X(w,c,h,e,S,s)


{ int p,O=          *l,t,d,o,C          ,*g,E,n,*m          =I,N=-1e8,
          A,L,r,x =           10,q; y=~y          ; H--O>20)
{ o=I[p=O]          D q=o^y,q>          0){ q+=(q<          2)*y,C=q
         ["51#/+++"],       A=q["95+3/33"];       do { m=0,
r=I[p+=C[l          ]-64] D !w          |p==w&&q>1          |C+2<A|!r)
          { d=abs(O-          p) D g=q<2          &e>>6==p+(
y?x:-x)?I+          (e>>6):0,           !r&(q>1|d%          x<1||g)|(r
          ^y)<-1){ n          =o,t=q<2&(          89<p|30>p)
?n+=y|1,6^          y:o+(y|1)           D (r^y)<-6          ) P 1e7-811
          *h; H n-t)          { O[I]=0,p          [I]=n,m?*g
=*m,*m=0:g          ?*g=0:0;            E=e&63 R(           91)16 R(28)
          4 R(21)2 R          (98)32; L=          (q>1?6-q?l
[p/x-1]-l[          O/x-1]-q+2          :(E|=y?8:1          ,!!m)*9:(E
          |=20-d?0:           64*p,n-o?(          l[15+n]-' '
)*9:d/8+!!          g*99))+(l[          r+15]-' ')          *9+l[p%x]-
          h-l[O%x];           L-=s>h||s==         h&L>49&1<s
?X(s>h?0:p          ,L,h+1,E,N          ,s):0 D !(          z-O|i-n|h|
          p-b|S|L<-           1e6))return         u=E; O[I]=
o,p[I]=r,m          ?*m=*g,*g=          0:g?*g=-2^          y:0 D S|h&&
          (L>N||!h&N          ==L&&rand(          )&4)){ N=L
D !h&&s) i          =n,z=O,b=p          D h&&c-L<S          ) P L; } q
          >5&d<2&C+6          <A&&(g=I+p          ,r=I[p+=p-
O],m=p<O?g          -3:g+2,!(e          &(p<O?3:5)          <<3*-y|*g|
          r|m[p<O?1:          -1])&&L>-           1e6&&1e6>a
63,1,0))?d          ++:(n+=y|1          );} } } C           +=q<2&C+3>
          A&((y?O<80          :39<O)||r)          ; } H!r&q>
2&q<6||(p=          O,++C<A))           ; } } P N+          1e8?N:0; }

HAHAHAHA! Sorry... When speaking about styles, I remembered this program, so I couldn't resist to make the joke!

@Avasam Avasam Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Have you seen the Donut rendering C code? :P

Jokes aside. If you don't mind either way, I'll use Ruff's implementation of isort, for the sole reason or not adding an additional tool and keeping configs centralised/simple.

Will do in separate PR, so you can merge this one.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This leads me to another comment of yours regarding formatters and autofixers. I have seen there is some "debate" on that, and it was funny to me that in some cases there was like a division between "old" and "young" coders... hahahaha!

I played around a little with autopep8... it's fine, but things like these look very weird to me:

        windows: list[str] = (str(ret[8:-2]).replace("[",
                                                     "").replace("]",
                                                                 "").replace("},{",
                                                                             "}|&|{").split("|&|"))
    x1, y1, w1, h1 = box1 if isinstance(
        box1, tuple) else (
        box1.left, box1.top, box1.width, box1.height)
    x2, y2, w2, h2 = box2 if isinstance(
        box2, tuple) else (
        box2.left, box2.top, box2.width, box2.height)

Given autopep8 acts more like an autofixer, it only does the minimum to wrap long lines. Without looking at the context. But you're still in control of manually wrapping more. (More control, less automation).

A formatter like black/ruff format, or YAPF work on an AST and so take code context into account. (less control, more automation).


And yeah there's always a bit of debate depending on team preferences. :P
I don't have a strong opinion styling-wise so I don't mind showing you different options.

@Avasam
Avasam force-pushed the resolve-Ruff-TODOs branch from fafbecc to bfd6649 Compare July 3, 2026 16:28
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.

2 participants