Saravanan666/pypi-org huggingface dataset:
Package: typeless-dataclasses
typeless-dataclasses: use dataclasses without variable annotationsHave you ever wanted to use dataclasses, but don't like type annotations?@dataclassclassData:one:Anytwo:Any=2... and don't want to resort to anyugly hackslike this one?@dataclassclassData:one:...two:...=2With the power oftypeless-dataclasses, now you can!@dataclass@typelessclassData:one=field()two=field(default=2)Compare withattrs:@attr.sclassData:one=attr.ib()two=attr.ib(default=2)InstallingInstall and update usingpip:$pipinstall--upgradetypeless-dataclassestypeless-dataclassesoffers a type-annotation-free experience for Python 3.6* and newer, and PyPy.(On 3.6, you also need to install the dataclassesbackport.)A Simple ExampleUsingtypeless-dataclassesis easy!Just add @typeless to your class before@dataclass, and usefield()as you normally would;field()attributes become instance variables, and all others remain class variables.>>>fromdataclassesimportdataclass,field>>>fromtypeless_dataclassesimporttypeless>>>>>>@dataclass...@typeless...classData:...one=field()...two=field(default=2)...three=3...>>>Data(1)Data(one=1,two=2)LinksDocumentation:https://github.com/lemon24/typeless-dataclasses/blob/master/README.mdChanges:https://github.com/lemon24/typeless-dataclasses/blob/master/CHANGES.mdPyPI Releases:https://pypi.org/project/typeless-dataclasses/Source Code:https://github.com/lemon24/typeless-dataclassesIssue Tracker:https://github.com/lemon24/typeless-dataclasses/issues
Package: typelift
Typelift - Basically worthlessDoesn’t do anything.InstallationInstall with pip:$ pip install typeliftUsageDo nothing:$ typelift http://www.example.comDo nothing, with EOT files instead:$ typelift http://www.example.com -f eotAlternate output directory (defaults to the current directory):$ typelift http://www.example.com -o downloadWARNINGUsage of Typelift is at your own risk and legal responsibility.LicenseTypelift is licensed under an MIT license. Please see the LICENSE file for more
information.
Package: typelint
typelinttypelintis a program that detects and reports typehints in
Python source code.List type hints:python -m typelint mypython.pyQuiet mode (number is reported as$?):python -m typelint --quiet mypython.pyIn either mode the number of typehints found is reported as the
program's exit status.
Counts above 99 are reported as 99
(so as to avoid overflowing the exit status value,
and to leave some room for reporting errors).Exit statusBecause the count is reported at the exit status and
the shell's convention is to treat 0 as true (success),
it is convenient to usetypelintas a test in shell scripts:if python typelint.py mypython.py
then
    echo "no typehints found"
else
    echo "typehints found"
fiEND
Package: typelog
Typelog - Static typed structured loggingDescriptionThis project araised from the need to log backend applications, aws lambdas and other stuff in modern cloud ecosystem. Logging systems today are able easily parsing JSON format out of the box.
Static typing approach brings here consistent way to define key values to final msg, as well as easier following Domain Driven Design, where logs consistently describe what they log. Static typed logging brings easy refactoring to any present logs.FeaturesAccepts static typed components as optional paramsit will not acceptanyoptionshas shortcut WithFields, to make clone of the logger with default logging fieldsEasy to turn on/off parameters by environment variablesAbility to define different log levels for different created loggersEasier turning complex objects into structured loggingaccepts maps and structs as its params. It will parse them on their own.See folder for up to date examplesAlternative VersionsVersion in golangPython specificsIn order to function with python extra well, recommendation to turn onstrict mypyor pyright in one ofits modsPublished at pypiHow to useinstall withpip install typelogexamples/types.pyfromdataclassesimportdataclassfromtypingimportNewTypeTaskID=NewType("TaskID",int)@dataclass(frozen=True)classTask:smth:strb:intexamples/logtypes.pyfromtypingimportAny,DictfromtypelogimportLogTypefrom.importtypesdefTaskID(value:types.TaskID)->LogType:defwrapper(params:Dict[str,Any])->None:params["task_id"]=str(value)returnwrapperdefTask(value:types.Task)->LogType:defwrapper(params:Dict[str,Any])->None:params.update(value.__dict__)returnwrapperexamples/test_examples.pyimportloggingimportunittestimporttypelogfromtypelogimportLogConfig,Loggers,get_loggerfromtypelog.typesimportLibName,LogLevel,RootLogLevelfrom.importlogtypes,typeslogger=get_logger(__name__)classTestExamples(unittest.TestCase):defsetUp(self)->None:Loggers(RootLogLevel(logging.DEBUG),LogConfig(LibName("examples"),LogLevel(logging.DEBUG)),add_time=True,).configure()deftest_basic(self)->None:logger.warn("Writing something",logtypes.TaskID(types.TaskID(123)))deftest_another_one(self)->None:task=types.Task(smth="abc",b=4)logger.warn("Writing something",logtypes.Task(task))deftest_with_fields(self)->None:logger2=logger.with_fields(logtypes.Task(types.Task(smth="aaa",b=1)))logger3=logger.with_fields(typelog.String("smth","asd"),typelog.Int("number",2))logger.info("logger printed")logger2.info("logger2 printed")logger3.info("logger3 printed")
Package: typemallow
typemallowAn elegant and automatic solution for generating/outputting Typescript interfaces from your Marshmallow SchemasI created this Package out of necessity for one of my own projects. Rather than keeping it to myself, I thought it would be helpful for other developers and my own future projects if I uploaded it.Usage:Using typemallow is simple.First, install the packagepip install typemallowNext, for your Marshmallow schemas that you wish to generate Typescript interfaces for, simply importts_interfaceandgenerate_tsfrom thetypemallowmodule, and prepend the@ts_interface()class decorator to your Marshmallow schema class.All that is required to generate your Typescript interfaces is to call thegenerate_ts()function, and provide a filepath as a parameter to output the result.main.pyfromtypemallowimportts_interface,generate_ts@ts_interface()classFoo(Schema):some_field=fields.Str()another_field=fields.Date()generate_ts('./output.ts')output.tsexportinterfaceFoo{some_field:string;another_field:date;}typemalloweven supports Nested Schema fields!main.pyfromtypemallowimportts_interface,generate_ts@ts_interface()classFoo(Schema):some_field=fields.Str()another_field=fields.Date()@ts_interface()classBar(Schema):foo=fields.Nested(Foo)foos=fields.Nested(Foo,many=True)bar_field=fields.Str()output.tsexportinterfaceFoo{some_field:string;another_field:date;}exportinterfaceBar{foo:Foo;foos:Foo[];bar_field:string;}Extended Usage:The@ts_interface()decorator function accepts an optional parameter,context, which defaults to... well... 'default'."Why is this the case?"When a Marshmallow Schema is identified with with@ts_interfacedecorator, it is added to a list in a dictionary of schemas, with the dictionary key being the value provided to thecontextparameter. If you were to provide different contexts for each schema, additional keys will be created if they do not exist, or the schema will simply be appended to the list at the existing key.This comes in handy, as thegenerate_ts()functionalsoaccepts an optionalcontextparameter, which will filter only schemas in the dictionary at the specific key.This is useful if you wish to output different contexts to different files, e.g.main.py...fromtypemallowimportts_interface,generate_ts@ts_interface(context='internal')classFoo(Schema):foo=fields.Str()@ts_interface(context='internal')classBar(Schema):bar=fields.Str()@ts_interface(context='external')classFooBar(Schema):foo_bar=fields.Str()'''we're telling typemallow that we only want to generate interfaces from Schemas withan 'internal' context to './internal.ts''''generate_ts('./internal.ts',context='internal')'''only generate interfaces from Schemas with an 'external' context to './external.ts''''generate_ts('./external.ts',context='external')internal.tsexportinterfaceFoo{foo:string;}exportinterfaceBar{bar:string;}external.tsexportinterfaceFooBar{foo_bar:string;}
Package: typemock
typemockType safe mocking for python 3.MotivationInstallationQuick example usageNOTE: This library is still in Alpha. Its API and implementation could change.Detailed DocumentationMotivationThe mocking tools in python are powerful, flexible and useful for building independent tests at various levels.This flexibility is part of what is considered a strength of the python language, and possibly any dynamically typed language.However, this flexibility comes at a cost.It is possible to build mocks which do not conform to the actual behaviour or contract defined by the things they are mocking. Or, for them to be initially correct, and then to go out of sync with actual behaviour and for tests to remain green.We do not have compile time protections for us doing things with/to things which do not align with the contracts they define and the clients of those contracts expect.But, now we have type hints. And so, we can explicitly define the contracts of our objects, and, if we have done this, we can mock them in a type safe way as well. This is what this library aims to help achieve. Type safe mocking.Used in conjunction with mypy, this should result in much more high fidelity independent tests.Installationpip install typemockQuick Example UsageGiven some class (the implementation of its method is not relevant)classMyThing:defmultiple_arg(self,prefix:str,number:int)->str:passMock and verifyWe con mock behaviour and verify interactions as follows:fromtypemockimporttmock,when,verifyexpected_result="a string"withtmock(MyThing)asmy_thing_mock:when(my_thing_mock.multiple_arg("p",1)).then_return(expected_result)actual=my_thing_mock.multiple_arg(number=1,prefix="p")assertexpected_result==actualverify(my_thing_mock).multiple_arg("p",1)Type safetyAnd when we try to specify behaviour that does not conform to the contract of the object we are mockingexpected_result="a string"withtmock(MyThing)asmy_thing_mock:when(my_thing_mock.multiple_arg(prefix="p",number="should be an int")).then_return(expected_result)We get an informative error such astypemock.safety.MockTypeSafetyError: Method: multiple_arg Arg: number must be of type:<class 'int'>
Package: typen
Strong Type Hints with TraitsThis package supplies simple decorators to enforce Python type hints on function parameters and return types.fromtypenimportenforce_type_hints@enforce_type_hintsdefhalve_integer(a:int)->float:returna/2halve_integer(5)# 2.5halve_integer(5.0)# ParameterTypeError@enforce_type_hintsdefgive_int(a)->int:returnagive_int(1)# 1give_int("a")# ReturnTypeErrorTrait Type HintsTraittypes can also be used to define complex patterns in type hintsfromtraits.apiimportArray,Either,Enum,Instance,Int,Str,Tuple@enforce_type_hintsdefcomplicated_function(a:Either(Str,Int),# Either a string or an intb:Enum(2,5,"foo"),# One of a specific set of valuesc:Instance(MyClass),# Class instancesd:Array(size=(None,2)),# Numpy array validation)->Tuple(Str,Either(Str,Int)):# Complicated return specification...Strict EnforcementType hints can also be required with the@strict_type_hintsdecorator. Both of the following examples will raise an exception when the function is first called. Without strict enforcement, parameters and return values without type hints can have any value.fromtypenimportstrict_type_hints@strict_type_hintsdefadd_numbers(a,b:float)->float:returna+badd_numbers(1,2)# UnspecifiedParameterTypeError@strict_type_hintsdefadd_numbers(a:float,b:float):returna+badd_numbers(1,2)# UnspecifiedReturnTypeErrorPacked args and kwargsType hints on packed parameters apply to all values passed through that packing.@enforce_type_hintsdeffoos_vs_bars(*foos:int,**bars:str)->bool:returnsum(foos)>=len(bars)foos_vs_bars(1,2,3,a="a",b="b",c="c")# Truefoos_vs_bars(2,3,5,d=4)# ParameterTypeErrorfoos_vs_bars(2,"three",5,e="e")# ParameterTypeErrorMethod DecorationMethods can be decorated as well.self-references are exempt from strict type hint requirements, as is the return type of__init__.@enforce_type_hintsand@strict_type_hintsshould decorate the product of the@classmethodor@staticmethoddecorators.classExClass:@strict_type_hintsdef__init__(self,a:int,b:int):...@strict_type_hints@classmethoddefa_class_method(cls,a:int,c:int)->int:...@strict_type_hints@staticmethoddefa_static_method(a:int,c:int)->int:...CoercionValues are enforced to types based onTrait type coercion. Casting behaviour is not added to the function:@enforce_type_hintsdefadd_numbers(a:float,b:float)->float:returna+btype(add_numbers(1,2))# intRecovering fromReturnTypeErrorBecause the function has to be executed to enforce the return value, the invalid value is stored on the exception. This makes it possible to recover from aReturnTypeErrorprogramatically.fromtypen.exceptionsimportReturnTypeError@enforce_type_hintsdefgive_int(a)->int:returnatry:give_int("a")exceptReturnTypeErroraserr:print(err.return_value)# a
Package: typename
TypenameThetypenamemodule defines a single function also calledtypenamewhich returns the name of the
type of any object as a string.Its purpose is purely aesthetic, to avoid unsightly constructs such astype(obj).__name__or the
ghastlyobj.__class__.__name__.InstallationThetypenamepackage is available on the Python Package Index (PyPI):Typenameshould work with any version of Python 3. To install:Withpipfrom PyPI:pip install typenameHow to use>>> from typename import typename
>>> x = 5
>>> typename(x)
'int'MIT LicenseCopyright (c) Sixty NorthPermission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Package: typepadapp-moderation
Get the moderation app:pip -E $VIRTUAL_ENV install -e git://github.com/sixapart/typepadapp-moderation.git#egg=typepadapp_moderationAdd the following to your urls.py:(r’^moderation’, include(‘moderation.urls’)),And include the following in your local_settings.py module:USE_MODERATION = Trueif USE_MODERATION:from settings import INSTALLED_APPS, TEMPLATE_CONTEXT_PROCESSORS## This is a location relative to MEDIA_ROOT and MEDIA_URL
## Make sure your web server has rights to create files there.
UPLOAD_PATH = ‘uploads’INSTALLED_APPS = (‘moderation’,) + INSTALLED_APPSTEMPLATE_CONTEXT_PROCESSORS += (‘moderation.context_processors.globals’, )## Customize this setting if you wish to alter the options shown
## when flagging a published post or comment:
# REPORT_OPTIONS = [
#     [“Option label”],
#     [“Admin: Suppress this post immediately”, 1]
# ]## Assign a Typepad Antispam API key here to make use of antispam
## filtering.
# TYPEPAD_ANTISPAM_API_KEY = ‘antispam-api-key’## For selective moderation; enabling this feature will default
## moderation so that it is only done for specific users.
# MODERATE_BY_USER = True## For selective moderation; enabling this feature will default
## moderation so that it is only done for these specific post types.
## Types are: post, photo, link, audio, video, comment
# MODERATE_TYPES = (‘photo’,)
Package: typepigeon
TypePigeonTypePigeon is a Python type converter focused on converting values between
various Python data types.pipinstalltypepigeonFeaturesconvert values directly from one Python type to another withconvert_value()convert values to JSON format withconvert_to_json()convert generic aliases (List[str]) to simple collection types ([str])
withguard_generic_alias()UsageWith TypePigeon, you can convert simple values from one type to another:convert_value()importtypepigeontypepigeon.to_type(0.55,str)'0.55'typepigeon.to_type(1,float)1.0typepigeon.to_type([1],str)'[1]'Additionally, you can also cast values into a collection:importtypepigeontypepigeon.to_type([1,2.0,'3'],[int])[1,2,3]typepigeon.to_type('[1, 2, 3]',(int,str,float))[1,'2',3.0]typepigeon.to_type({'a':2.5,'b':4,3:'18'},{str:float}){'a':2.5,'b':4.0,'3':18.0}Some commonly-used classes such asdatetimeandCRSare also supported:fromdatetimeimportdatetime,timedeltafrompyprojimportCRSimporttypepigeontypepigeon.to_type(datetime(2021,3,26),str)'2021-03-26 00:00:00'typepigeon.to_type('20210326',datetime)datetime(2021,3,26)typepigeon.to_type('01:13:20:00',timedelta)timedelta(days=1,hours=13,minutes=20,seconds=0)typepigeon.to_type(timedelta(hours=1),str)'01:00:00.0'typepigeon.to_type(timedelta(hours=1),int)3600typepigeon.to_type(CRS.from_epsg(4326),int)4326typepigeon.to_type(CRS.from_epsg(4326),str)'GEOGCRS["WGS 84",ENSEMBLE["World Geodetic System 1984 ensemble",MEMBER["World Geodetic System 1984 (Transit)"],MEMBER["World Geodetic System 1984 (G730)"],MEMBER["World Geodetic System 1984 (G873)"],MEMBER["World Geodetic System 1984 (G1150)"],MEMBER["World Geodetic System 1984 (G1674)"],MEMBER["World Geodetic System 1984 (G1762)"],ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]],ENSEMBLEACCURACY[2.0]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["Horizontal component of 3D system."],AREA["World."],BBOX[-90,-180,90,180]],ID["EPSG",4326]]'typepigeon.to_type(4326,CRS)CRS.from_epsg(4326)convert_to_json()fromdatetimeimportdatetimeimporttypepigeontypepigeon.to_json(5)5typepigeon.to_json('5')'5'typepigeon.to_json(datetime(2021,3,26))'2021-03-26 00:00:00'typepigeon.to_json([5,'6',{3:datetime(2021,3,27)}])[5,'6',{3:'2021-03-27 00:00:00'}]typepigeon.to_json({'test':[5,'6',{3:datetime(2021,3,27)}]}){'test':[5,'6',{3:'2021-03-27 00:00:00'}]}guard_generic_alias()importtypepigeon.typesfromtypingimportDict,List,Tupleimporttypepigeontypepigeon.types.subscripted_type(List[str])[str]typepigeon.types.subscripted_type(Dict[str,float]){str:float}typepigeon.types.subscripted_type({str:(Dict[int,str],str)}){str:({int:str},str)}
Package: typepy
typepySummaryFeaturesInstallationInstallation: pipInstallation: condaInstallation: aptDependenciesOptional dependenciesUsageType Check MethodType Validation MethodType Conversion MethodsFor more informationDocumentationSummarytypepyis a Python library for variable type checker/validator/converter at a run time.Featureschecking a value typevalidate a value for a typeconvert a value from one type to the other typeThe correspondence between Python types andtypepyclasses are as follows:Supported TypesPython Typetypepy: Type ClassboolBooldatetimeDateTimedictDictionaryfloat/decimal.Decimal(not infinity/NaN)RealNumberfloat/decimal.Decimal(infinity)Infinityfloat/decimal.Decimal(NaN)NanintIntegerlistListNoneNonestr(not null)Stringstr(null)NullStringstr(IP address)IpAddressInstallationInstallation: pippip install typepyInstall additional dependency packages with the following command if usingtypepy.DateTimeclasspip install typepy[datetime]Installation: condaconda install -c conda-forge typepyInstallation: aptsudo add-apt-repository ppa:thombashi/ppa
sudo apt update
sudo apt install python3-typepyDependenciesPython 3.7+Python package dependencies (automatically installed)Optional dependenciesThese packages can be installed viapip install typepy[datetime]:python-dateutilpytzUsageType Check MethodExamples:>>>fromtypepyimportInteger>>>Integer(1).is_type()True>>>Integer(1.1).is_type()FalseType Validation MethodExamples:>>>fromtypepyimportInteger>>>Integer(1).validate()>>>try:...Integer(1.1).validate()...exceptTypeErrorase:...# validate() raised TypeError when the value unmatched the type class...print(e)...invalid value type: expected=INTEGER, actual=<type 'float'>Type Conversion Methodsconvert methodExamples:>>>fromtypepyimportInteger,TypeConversionError>>>Integer("1").convert()1>>>try:...Integer(1.1).convert()...exceptTypeConversionErrorase:...# convert() raised TypeConversionError when conversion failed...print(e)...failed to convert from float to INTEGERtry_convert methodExamples:>>>fromtypepyimportInteger>>>Integer("1").try_convert()1>>>print(Integer(1.1).try_convert())# try_convert() returned None when conversion failedNoneforce_convertExamples:>>>fromtypepyimportInteger,TypeConversionError>>>Integer("1").force_convert()# force_convert() forcibly convert the value1>>>Integer(1.1).force_convert()1>>>try:...Integer("abc").force_convert()...exceptTypeConversionErrorase:...# force_convert() raised TypeConversionError when the value was not convertible...print(e)...failed to force_convert to int: type=<class 'str'>For more informationType check/validate/convert results differed according tostrict_levelvalue which can pass to typepy class constructors as an argument.
More information can be found in theAPI reference.Documentationhttps://typepy.rtfd.io/
Package: typeracer-cheat
typeracer-cheatA program that allows one to achieve extremely high speeds on typeracer.com on all game modes.Demo:https://user-images.githubusercontent.com/59426357/174093466-ce797f7b-86ba-4228-a056-cb46d174a1b9.mp4Install:Python 3.6 or higher is requiredpip3installtyperacer_cheatUsage:To run cheat, entertype_cheatin command line.Change typing speedTo change the typing speed, locate this line inmain.py:time.sleep(.009)Change the value inside the parentheses:.009means that the typing speed is 1 character every .009 seconds, or 1 character every 9-thousandth of a second.
Package: typerassistant
TyperAssistantInstantly turn any python Typer CLI in to a function-calling OpenAI assistant.ExampleTyperapp:importgetpassimporttyperfromtyperassistantimportregister_assistantapp=typer.Typer()register_assistant(app)@app.command()defsay_hello(name:str):print(f"Hello,{name}!")@app.command()defget_current_user():print(getpass.getuser())if__name__=="__main__":app()Example CLI usage:InstallingTyperAssistant usespoetryfor a build system, so you can
safely install it like you would any python package.$pipinstalltyperassistantOr, with poetry:$poetryaddtyperassistantUsagePlease be aware that OpenAI's API incurs fees.SeeOpenAI's help article on the
subjectfor more information.A documentation pass is planned before the 1.0 release, but at this time the best way to learn how to use
TyperAssistant's features is to go check out theexamples/directory. You can also see that the maintyperassistantpackage only exports three members:Assistant, a basic frontend for OpenAI's Assistant API that handles function calling and threads.TyperAssistant, anAssistantsubclass which wraps a Typer application.register_assistant(app: Typer), a function which registers an "ask" command and automatically generates an
appropriate assistant for your application.Most use cases require onlyregister_assistant(app)to begin working immediately!ContributingPatches are welcome, as are questions, suggestions, and example usecases! TyperAssistant is still in very early development, and I
am hoping to find some excited collaborators to help build the roadmap to 1.0.For now, please use the github Issues feature, but I plan to investigate further as needs dictate.LicenseThis software is licensed with the MIT license. Please see the fileLICENSEfor more information.TyperAssistant is copyright Erich Blume, 2023.