Streamline Python file headers somewhat

- Add coding statement
  - Import all modules in one line where possible
  - Order: __future__, typing, plain imports, from imports,
    janware modules

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2025-07-10 05:14:06 +02:00
commit 428692ea3a
21 changed files with 50 additions and 40 deletions

View file

@ -1,17 +1,16 @@
# -*- coding: utf-8 -*-
from __future__ import annotations from __future__ import annotations
from typing import List, Type, Union, TypeVar from typing import List, Type, Union, TypeVar
import abc import inspect, sys, re, abc, argparse
import argparse
from abc import ABC
from argparse import ArgumentParser, _SubParsersAction from argparse import ArgumentParser, _SubParsersAction
import inspect, sys, re
from jwutils import log from jwutils import log
# full blown example of one level of nested subcommands # full blown example of one level of nested subcommands
# git -C project remote -v show -n myremote # git -C project remote -v show -n myremote
class Cmd(ABC): # export class Cmd(abc.ABC): # export
@abc.abstractmethod @abc.abstractmethod
async def run(self, args): async def run(self, args):

View file

@ -1,15 +1,8 @@
import os # -*- coding: utf-8 -*-
import sys
import argparse
import importlib
import inspect
import re
import pickle
import asyncio
from argparse import ArgumentParser
from typing import Optional
import cProfile from typing import Optional
import os, sys, argparse, importlib, inspect, re, pickle, asyncio, cProfile
from argparse import ArgumentParser
import jwutils import jwutils
from jwutils.log import * from jwutils.log import *

View file

@ -1,11 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os
import re
import glob
import sys
from pathlib import Path, PosixPath
from typing import Optional, Dict, cast from typing import Optional, Dict, cast
import os, re, glob, sys
from pathlib import Path, PosixPath
from jwutils import stree from jwutils import stree
from .stree.StringTree import StringTree from .stree.StringTree import StringTree

View file

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
class CppState: # export class CppState: # export
def __init__(self): def __init__(self):

View file

@ -1,4 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import print_function from __future__ import print_function
import jwutils.log import jwutils.log
class Object(object): # export class Object(object): # export

View file

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import annotations from __future__ import annotations
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from enum import Enum, Flag, auto from enum import Enum, Flag, auto

View file

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import print_function from __future__ import print_function
import os
import io import os, io, sys, traceback
import sys
import traceback
from fcntl import fcntl, F_GETFL, F_SETFL from fcntl import fcntl, F_GETFL, F_SETFL
class RedirectStdIO: # export class RedirectStdIO: # export

View file

@ -1,5 +1,7 @@
from abc import ABC, abstractmethod # -*- coding: utf-8 -*-
from typing import Dict, Callable from typing import Dict, Callable
from abc import ABC, abstractmethod
_handled_signals: Dict[int, Callable] = {} _handled_signals: Dict[int, Callable] = {}

View file

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from datetime import datetime from datetime import datetime
from .log import * from .log import *
class StopWatch: # export class StopWatch: # export

View file

@ -1,5 +1,6 @@
import re, shlex # -*- coding: utf-8 -*-
import re, shlex
from collections import namedtuple from collections import namedtuple
from ..log import * from ..log import *

View file

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
from abc import abstractmethod from abc import abstractmethod
from ..Process import Process as ProcessBase from ..Process import Process as ProcessBase

View file

@ -1,4 +1,7 @@
# -*- coding: utf-8 -*-
import asyncio import asyncio
from ..Signals import Signals as SignalsBase from ..Signals import Signals as SignalsBase
class Signals(SignalsBase): class Signals(SignalsBase):

View file

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
# >> -------------------------- generated by python-tools.sh >> # >> -------------------------- generated by python-tools.sh >>
from jwutils.asyncio.Process import Process from jwutils.asyncio.Process import Process
# << -------------------------- generated by python-tools.sh << # << -------------------------- generated by python-tools.sh <<

View file

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import io import io, os, re, textwrap, json, csv
import os, re, textwrap, json, csv
from tabulate import tabulate # type: ignore from tabulate import tabulate # type: ignore
from jwutils.log import * from jwutils.log import *

View file

@ -4,9 +4,8 @@ from typing import Optional, Any
import abc import abc
from ...log import *
from .DataType import DataType from .DataType import DataType
from ...log import *
class Column(abc.ABC): # export class Column(abc.ABC): # export

View file

@ -1,11 +1,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from typing import Optional from typing import Optional
from ...log import *
from enum import Enum, auto from enum import Enum, auto
from datetime import datetime from datetime import datetime
from ...log import *
class Id(Enum): class Id(Enum):
Integer = auto() Integer = auto()
SmallInteger = auto() SmallInteger = auto()

View file

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import print_function from __future__ import print_function
from typing import List, Tuple, Optional, Any from typing import List, Tuple, Optional, Any
@ -6,6 +8,7 @@ import sys, re, io, syslog, inspect
from os.path import basename from os.path import basename
from datetime import datetime from datetime import datetime
from . import misc from . import misc
# --- python 2 / 3 compatibility stuff # --- python 2 / 3 compatibility stuff

View file

@ -1,10 +1,6 @@
import os, errno # -*- coding: utf-8 -*-
import atexit
import tempfile import os, errno, atexit, tempfile, filecmp, inspect, importlib, re
import filecmp
import inspect
import importlib
import re
from typing import Set, Iterable from typing import Set, Iterable

View file

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
''' '''
Created on 26 May 2013 Created on 26 May 2013

View file

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import annotations from __future__ import annotations
from typing import Any, List, Optional, Union from typing import Any, List, Optional, Union

View file

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
import os import os
from jwutils.stree.StringTree import * from jwutils.stree.StringTree import *