Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Highlight typing hints in a different color than ordinary code. #183
Comments
|
I agree. Would be nice to be able to apply a different color to type hints. I get the impression a lot of people like them to be just regular code. I'm fine with that as the default, but would be nice to add an extra label so some of us can for example make all type hints semi-transparent. |
|
There are also the type hints on function defs. And they very much deserve some highlighting. def fun_func(
big_param: Set[Tuple[int, int]],
generic_param: List[T],
) -> Mapping[str, T]: ... |
|
Type annotations of the attributes of a dataclass need proper highlighting as well: Number = Union[int, float]
@dataclass(frozen=True)
class SomeClass:
foo: Generator[AnyStr, Number, None] = field(hash=False)
bar: Iterable[T] = field(compare=False)
amount: Number = -1 |
|
When using generic types (typevar) on classes (inheriting from it), no highlighting appears. V = TypeVar("V", FirstType, SomeOtherType)
E = TypeVar("E")
class StopIgnoringMe(Generic[V, E], ParentClass):
pass
class NormalInheritance(ParentClass):
pass |
|
I'll see what I can do to highlight type hints better. I guess the starting point would be to at least give them all a scope of their own like |
|
@vpetrovykh do you need help with the issue? |
|
It appears Github's highlighting decided that everything that starts with a capital letter deserves that same color. |
|
I'd also like to have a separate scope for type hints. |
Typing hints are displayed in the same color as python variables and statements.
That looks somewhat confusing and makes it harder to see at once where is a typing hint, where a variable name is defined and where is an actual code.
E.g., the line below up to 'origin' is in the same color.