Force you (or your user) annotate Python function type hints.

Overview

Must-typing

Force you (or your user) annotate function type hints.

Notice: It's more like a joke, use it carefully.

If you call must_typing in your module, all your user will be affected.

Requirement

  • Python3.6+

Usage

from musttyping import must_typing

# Your code

must_typing()

once a function lack of annotation...

musttyping.must_typing() File "musttyping\__init__.py", line 23, in must_typing raise LackAnnotationException(f"{obj} need type annotation(s)") musttyping.LackAnnotationException: need type annotation(s)">
Function 'f' located in test.py at line 4
>> def f():
    def f():
        ...
    ...

>> It lack of Return type annotation <<
Traceback (most recent call last):
  File "test.py", line 11, in 
    
     
    musttyping.must_typing()
  File "musttyping\__init__.py", line 23, in must_typing
    raise LackAnnotationException(f"{obj} need type annotation(s)")
musttyping.LackAnnotationException: 
     
       need type annotation(s)

     
    

Under the hood

must_typing will scan all function objects in current runtime, and pick out those defined by user.

Then, it will check if the function lack of annotation, and raise an exception.

It will only scan functions defined by user, which means all function in other module would be ignored, including Python builtin modules and 3rd party modules.

Once must_typing detect running in debugger, it would be turned off automatically.

detect targets

  • user defined functions
  • user defined class methods

non detect targets

  • builtin and 3rd party module functions
  • functions written in C
  • lambda functions
  • functions defined in closure
  • functions defined in other thread (coming soon)
  • return annotation in class magic methods

Why this package

Just for fun.

It's better to use --disallow-untyped-calls in mypy or some other equivalents.

License

MIT

Owner
Konge
Member of @XDSEC. Cybersecurity and Cryptography enthusiast. Python / Rust / C OpenPGP key -> 0xEE4C7A6604F78980
Konge
This is a Docker-based pipeline for preparing sextractor-ready multiwavelength images

Pipeline for creating NB422-detected (ODI) catalog The repository contains a Docker-based pipeline for preprocessing observational data. The pipeline

1 Sep 01, 2022
Why write code when you can import it directly from GitHub Copilot?

Copilot Importer Why write code when you can import it directly from GitHub Copilot? What is Copilot Importer? The copilot python module will dynamica

Mythic 41 Jan 04, 2023
Python - Aprendendo Python na ByLearn

PYTHON Identação Escopo Pai Escopo filho Escopo neto Variaveis

Italo Rafael 3 May 31, 2022
Return-Parity-MDP - Towards Return Parity in Markov Decision Processes

Towards Return Parity in Markov Decision Processes Code for the AISTATS 2022 pap

Jianfeng Chi 3 Nov 27, 2022
Simple dependency injection framework for Python

A simple, strictly typed dependency injection library.

BentoML 14 Jun 29, 2022
Fithub is a website application for athletes and fitness enthusiasts of all ages and experience levels.

Fithub is a website application for athletes and fitness enthusiasts of all ages and experience levels. Our website allows users to easily search, filter, and sort our comprehensive database of over

Andrew Wu 1 Dec 13, 2021
Really bad lisp implementation. Fun with pattern matching.

Lisp-py This is a horrible, ugly interpreter for a trivial lisp. Don't use it. It was written as an excuse to mess around with the new pattern matchin

Erik Derohanian 1 Nov 23, 2021
An universal linux port of deezer, supporting both Flatpak and AppImage

Deezer for linux This repo is an UNOFFICIAL linux port of the official windows-only Deezer app. Being based on the windows app, it allows downloading

Aurélien Hamy 154 Jan 06, 2023
Users can read others' travel journeys in addition to being able to upload and delete posts detailing their own experiences

Users can read others' travel journeys in addition to being able to upload and delete posts detailing their own experiences! Posts are organized by country and destination within that country.

Christopher Zeas 1 Feb 03, 2022
The LiberaPay archive module for the SeanPM life archive project.

By: Top README.md Read this article in a different language Sorted by: A-Z Sorting options unavailable ( af Afrikaans Afrikaans | sq Shqiptare Albania

Sean P. Myrick V19.1.7.2 1 Aug 26, 2022
This program generates automatically new folders containing old version of program

Automated Folder Versions Generator by Sergiy Grimoldi - V.0.0.2 This program generates automatically new folders containing old version of something

Sergiy Grimoldi 1 Dec 23, 2021
Contains a Jupyter Notebook for calculating remaining plants required based on field/lathhouse data.

Davis-Sunflowers-Su21 Project goals: Plants influence their reproduction and mating system in many ways. Various factors such as time of flowering, ab

1 Feb 10, 2022
Library support get vocabulary from MEM

Features: Support scraping the courses in MEM to take the vocabulary Translate the words to your own language Get the IPA for the English course Insta

Joseph Quang 4 Aug 13, 2022
Data wrangling & common calculations for results from qMem measurement software

qMem Datawrangler This script processes output of qMem measurement software into an Origin ® compatible *.csv files and matplotlib graphs to quickly v

Julian 1 Nov 30, 2021
The most hackable keyboard in all the land

MiRage Modular Keyboard © 2021 Zack Freedman of Voidstar Lab Licensed Creative Commons 4.0 Attribution Noncommercial Share-Alike The MiRage is a 60% o

Zack Freedman 558 Dec 30, 2022
Automatização completa do site https://blaze.com

PyBlaze Pyblaze possibilita o acesso a api do site blaze utilizando python, retornando os últimos resultados de crashs e doubles. Agora também é possí

Cleiton Leonel 24 Dec 30, 2022
A script for creating battle animations in FEGBA format.

AA2 Made by Huichelaar. I heavily referenced FEBuilderGBA. I also referenced circleseverywhere's Animation Assembler. This is also where I took lzss.p

2 May 31, 2022
The bidirectional mapping library for Python.

bidict The bidirectional mapping library for Python. Status bidict: has been used for many years by several teams at Google, Venmo, CERN, Bank of Amer

Joshua Bronson 1.2k Dec 31, 2022
Prophet is a tool to discover resources detailed for cloud migration, cloud backup and disaster recovery

Prophet is a tool to discover resources detailed for cloud migration, cloud backup and disaster recovery

22 May 31, 2022
ArinjoyTheDev 1 Jul 17, 2022