peps | Python Enhancement Proposals

 by   python Python Version: last-legacy-rendering-system License: No License

kandi X-RAY | peps Summary

kandi X-RAY | peps Summary

peps is a Python library. peps has no bugs, it has no vulnerabilities, it has build file available and it has medium support. You can download it from GitHub.

Python Enhancement Proposals
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              peps has a medium active ecosystem.
              It has 3784 star(s) with 1480 fork(s). There are 256 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 25 open issues and 315 have been closed. On average issues are closed in 24 days. There are 15 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of peps is last-legacy-rendering-system

            kandi-Quality Quality

              peps has 0 bugs and 0 code smells.

            kandi-Security Security

              peps has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              peps code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              peps does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              peps releases are not available. You will need to build from source code and install.
              Build file is available. You can build the component from source.
              peps saves you 1251 person hours of effort in developing the same functionality from scratch.
              It has 2886 lines of code, 178 functions and 37 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed peps and discovered the below as its top functions. This is intended to give you an instant insight into peps implemented functionality, and help decide if they suit your requirements.
            • Parse the document tree
            • Mask email address
            • Return the item name and type
            • Generate the URL for a mail address
            • Apply the contents of the document
            • Return a paragraph containing the last modified time
            • Post build
            • Create the index file
            • Apply the contents of the PEP file
            • Parse text into nodes
            • Visit if
            • Return the name of a node
            • Create index file
            • Return the current monotonic clock
            • Summarize a list of files
            • Format a duration in seconds
            • Load projects from cache
            • Creates the PEP 0 XML file
            • Create argument parser
            • Matches ifExp
            • Generate documentation for subindices
            • Decorator to count the number of calls
            • Visit Boolean operator
            • Log text to file
            • Return first line starting with text
            • Creates an instance of an author
            • Get the timestamps of the last modified files
            Get all kandi verified functions for this library.

            peps Key Features

            No Key Features are available at this moment for peps.

            peps Examples and Code Snippets

            What's new in 0.23.0 (May 15, 2018)
            Pythondot img1Lines of Code : 1036dot img1License : Permissive (BSD-3-Clause)
            copy iconCopy
            
            .. _whatsnew_0230.enhancements.round-trippable_json:
            
            JSON read/write round-trippable with ``orient='table'``
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            
            A ``DataFrame`` can now be written to and subsequently read back via JSON while pr  
            What's new in 1.0.0 (January 29, 2020)
            Pythondot img2Lines of Code : 461dot img2License : Permissive (BSD-3-Clause)
            copy iconCopy
            The pandas 1.0 release removed a lot of functionality that was deprecated
            in previous releases (see :ref:`below `
            for an overview). It is recommended to first upgrade to pandas 0.25 and to
            ensure your code is working without warnings, before upgradin  
            copy iconCopy
            SELECT DISTINCT rel_label, rel_key FROM hermes_relation;
            
            SELECT hr.target_name_norm, COUNT(*)
                FROM hermes_relation AS hr, pep AS pe
                WHERE
                    hr.target_name_norm IS NOT NULL
                    AND LENGTH(hr.target_name_norm) > 2
                    AND hr.r  
            Matrix multiplication .
            pythondot img4Lines of Code : 225dot img4License : Non-SPDX (Apache License 2.0)
            copy iconCopy
            def matmul(a,
                       b,
                       transpose_a=False,
                       transpose_b=False,
                       adjoint_a=False,
                       adjoint_b=False,
                       a_is_sparse=False,
                       b_is_sparse=False,
                       output_type=None,
                       name=N  
            Decorator to apply a function to a string or collection of rules .
            pythondot img5Lines of Code : 51dot img5License : Permissive (MIT License)
            copy iconCopy
            def run_with_stringy(fn):
                """Run a string function with a string or a collection of strings.
            
                We define a custom decorator that allows us to convert a function whose
                input is a single string into a function whose input can be a string
                 
            Normalize a docstring .
            pythondot img6Lines of Code : 39dot img6License : Non-SPDX (Apache License 2.0)
            copy iconCopy
            def _normalize_docstring(docstring):
              """Normalizes the docstring.
            
              Replaces tabs with spaces, removes leading and trailing blanks lines, and
              removes any indentation.
            
              Copied from PEP-257:
              https://www.python.org/dev/peps/pep-0257/#handling-d  

            Community Discussions

            QUESTION

            Is there any difference between using a decorator and applying the function directly?
            Asked 2022-Apr-17 at 22:00

            I recently became the maintainter of PyPDF2 - a library which is pretty old and still has some code that deals with Python versions before 2.4. While I want to drop support for 3.5 and older soon, I see some parts where I'm uncertain why they were written as they are.

            One example is this:

            What is in the code:

            ...

            ANSWER

            Answered 2022-Apr-17 at 22:00

            The first version is just the pre-2.4 way to use staticmethod. The two versions aren't quite equivalent, but the difference is so tiny it almost never matters.

            Specifically, on Python versions that support decorator syntax, the one difference is that the second version passes the original function directly to staticmethod, while the first version stores the original function to a and then looks up the a variable to find the argument to pass to staticmethod. This can technically matter in very weird use cases, particularly with metaclasses, but it'd be highly unlikely. Python 2 doesn't even support the relevant metaclass feature (__prepare__).

            Source https://stackoverflow.com/questions/71905698

            QUESTION

            Python coding standard for Safety Critical Applications
            Asked 2022-Mar-20 at 15:46

            Coming from C/C++ background, I am aware of coding standards that apply for Safety Critical applications (like the classic trio Medical-Automotive-Aerospace) in the context of embedded systems , such as MISRA, SEI CERT, Barr etc.

            Skipping the question if it should or if it is applicable as a language, I want to create Python applications for embedded systems that -even vaguely- follow some safety standard, but couldn't find any by searching, except from generic Python coding standards (like PEP8)

            Is there a Python coding guideline that specificallly apply to safety-critical systems ?

            ...

            ANSWER

            Answered 2022-Feb-02 at 08:46

            Top layer safety standards for "functional safety" like IEC 61508 (industrial), ISO 26262 (automotive) or DO-178 (aerospace) etc come with a software part (for example IEC 61508-3), where they list a number of suitable programming languages. These are exclusively old languages proven in use for a long time, where all flaws and poorly-defined behavior is regarded as well-known and execution can be regarded as predictable.

            In practice, for the highest safety levels it means that you are pretty much restricted to C with safe subset (MISRA C) or Ada with safe subset (SPARK). A bunch of other old languages like Modula-2, Pascal and Fortran are also mentioned, but the tool support for these in the context of modern safety MCUs is non-existent. As is support for Python for such MCUs.

            Languages like Python and C++ are not even mentioned for the lowest safety levels, so between the lines they are dismissed as entirely unsuitable. Even less so than pure assembler, which is actually mentioned as something that may used for the lower safety levels.

            Source https://stackoverflow.com/questions/69673807

            QUESTION

            Python: use Type Hints together with Annotations
            Asked 2022-Mar-15 at 06:53

            In Python, we all know Type hints, which became available from 2015:

            ...

            ANSWER

            Answered 2022-Mar-14 at 15:01

            Since an annotation can be any expression (as far as the Python interpreter is concerned), you can technically do something like using a tuple as your annotation:

            Source https://stackoverflow.com/questions/71469513

            QUESTION

            datetime timestamp using Python with microsecond level accuracy
            Asked 2022-Feb-26 at 12:56

            I am trying to get timestamps that are accurate down to the microsecond on Windows OS and macOS in Python 3.10+.

            On Windows OS, I have noticed Python's built-in time.time() (paired with datetime.fromtimestamp()) and datetime.datetime.now() seem to have a slower clock. They don't have enough resolution to differentiate microsecond-level events. The good news is time functions like time.perf_counter() and time.time_ns() do seem to use a clock that is fast enough to measure microsecond-level events.

            Sadly, I can't figure out how to get them into datetime objects. How can I get the output of time.perf_counter() or PEP 564's nanosecond resolution time functions into a datetime object?

            Note: I don't need nanosecond-level stuff, so it's okay to throw away out precision below 1-μs).

            Current Solution

            This is my current (hacky) solution, which actually works fine, but I am wondering if there's a cleaner way:

            ...

            ANSWER

            Answered 2022-Feb-26 at 12:56

            That's almost as good as it gets, since the C module, if available, overrides all classes defined in the pure Python implementation of the datetime module with the fast C implementation, and there are no hooks.
            Reference: python/cpython@cf86e36

            Note that:

            1. There's an intrinsic sub-microsecond error in the accuracy equal to the time it takes between obtaining the system time in datetime.now() and obtaining the performance counter time.
            2. There's a sub-microsecond performance cost to add a datetime and a timedelta.

            Depending on your specific use case if calling multiple times, that may or may not matter.

            A slight improvement would be:

            Source https://stackoverflow.com/questions/71087502

            QUESTION

            What is the scope of the `as` binding in an `except` statement or context manager?
            Asked 2022-Feb-24 at 21:26

            I know that in general python only makes new scopes for classes, functions etc., but I'm confused by the as statement in a try/except block or context manager. Variables assigned inside the block are accessible outside it, which makes sense, but the variable bound with as itself is not.

            So this fails:

            ...

            ANSWER

            Answered 2022-Feb-24 at 20:58

            This is a documented exception to the normal rules that *specifically applies to try-except statements, from the language reference:

            When an exception has been assigned using as target, it is cleared at the end of the except clause. This is as if:

            Source https://stackoverflow.com/questions/71257947

            QUESTION

            How can I perform a type guard on a property of an object in Python
            Asked 2022-Feb-24 at 12:42

            PEP 647 introduced type guards to perform complex type narrowing operations using functions. If I have a class where properties can have various types, is there a way that I can perform a similar type narrowing operation on the property of an object given as the function argument?

            ...

            ANSWER

            Answered 2022-Feb-24 at 12:42

            TypeGuard annotations can be used to annotate subclasses of a class. If parameter types are specified for those classes, then MyPy will recognise the type narrowing operation successfully.

            Source https://stackoverflow.com/questions/71029876

            QUESTION

            Annotate dataclass class variable with type value
            Asked 2022-Feb-22 at 14:53

            We have a number of dataclasses representing various results with common ancestor Result. Each result then provides its data using its own subclass of ResultData. But we have trouble to annotate the case properly.

            We came up with following solution:

            ...

            ANSWER

            Answered 2022-Jan-31 at 15:10

            As hinted in the comments, the _data_cls attribute could be removed, assuming that it's being used for type hinting purposes. The correct way to annotate a Generic class defined like class MyClass[Generic[T]) is to use MyClass[MyType] in the type annotations.

            For example, hopefully the below works in mypy. I only tested in Pycharm and it seems to infer the type well enough at least.

            Source https://stackoverflow.com/questions/70861001

            QUESTION

            How to type hint an instance-level function (i.e. not a method)?
            Asked 2022-Feb-03 at 17:05

            Instance attributes are typically annotated on the class:

            ...

            ANSWER

            Answered 2022-Feb-03 at 17:05

            This is currently broken in mypy as it assumes you are creating a method, here is the relevant issue https://github.com/python/mypy/issues/708.

            Typing the function in the init works fine as it won't think it's a method on the class, the following code passes type checking properly and func's type is inferred from the parameter. The attribute assignment can also be typed directly if the parameter is not viable.

            Source https://stackoverflow.com/questions/70974078

            QUESTION

            Creating a module subclass in a Python extension
            Asked 2022-Jan-06 at 17:50

            I am trying to create a Python extension module with multi-phase initialization, following the advice I got from a previous question. PEP 489 suggests that it is preferable for the Py_mod_create function to return a module subclass, which presumably means a subclass of PyModule, but I cannot figure out how to do this. In all my attempts, the module segfaults when it is imported. It works fine if Py_mod_create returns some other object, (one which is not a subclass of PyModule), but I am not sure if this will cause problems in future, since isinstance(mymodule, types.ModuleType) returns false in this case.

            Following the docs on subclassing built-in types, I set tp_base to PyModule_Type, and my tp_init function calls PyModule_Type.tp_init. The docs also suggest that my structure should contain the superclass structure at the beginning, which in this case is PyModuleObject. This structure is not in the public Python header files, (it is defined in moduleobject.c in the Python sources), so for now I copied and paste the definitions of the PyModuleObject fields at the start of my structure. The complete code looks like this:

            ...

            ANSWER

            Answered 2022-Jan-06 at 17:50

            After some tests I could build a custom module type by copying parts of code from moduleobject.c

            Your problem is that your code does create an instance of a subclass of module, but never initializes it and gets random values in key members. Additionaly, modules are expected to be gc collectables, so you have to create your custom module with PyObject_GC_New.

            The following code replaces your initial testmod_create function with a full initialization of the module:

            Source https://stackoverflow.com/questions/70608438

            QUESTION

            Union of generic types that is also generic
            Asked 2022-Jan-05 at 05:31

            Say I have two types (one of them generic) like this

            ...

            ANSWER

            Answered 2022-Jan-05 at 05:31

            Rereading the mypy documentation I believe I have found my answer:

            Type aliases can be generic. In this case they can be used in two ways: Subscripted aliases are equivalent to original types with substituted type variables, so the number of type arguments must match the number of free type variables in the generic type alias. Unsubscripted aliases are treated as original types with free variables replaced with Any

            So, to answer my question:

            Source https://stackoverflow.com/questions/70583230

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install peps

            You can download it from GitHub.
            You can use peps like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/python/peps.git

          • CLI

            gh repo clone python/peps

          • sshUrl

            git@github.com:python/peps.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link